php页面中左上角的奇怪边距

时间:2017-01-28 21:58:11

标签: php html css

大家好我正在构建一个带有bootstrap的php网页,我的身体顶部,右侧和左侧都有边距。 在this问题后,我下载了记事本++并转换为没有BOM的utf-8,但边距仍然存在。

这是我的css文件

  .texts{
   color: white;
}

.mainbody{
   margin-top: 0;
   max-width: 1200px;
 }
 .banner{
   height : 600px;
   width : 100%;
   max-width:100%;
   background-image:  url("restrooms.jpg");
   background-size: cover;
   background-repeat: no-repeat;
 }

 .bannertext{
   color: white;

 }
 .bannerbg{
   background-color: #a52f0b;
   opacity: 0.7;
   margin-left: 40px;
   height :150px

 }
 .dashform{
   margin-top: 10px;
   margin-bottom: 10px;
   border-style: solid;
   border-width: 1px;
 }
 .mtop{
   margin-top: 6px;
 }
 .blbc{
   background-color: #424242;


 }
 .im-centered{margin: auto; max-width: 100%;}

这里是index.php

 <?php
 include ('header.html');
 ?>
 <div class="w3-container w3-center">
 <div class="w3-container banner">
 <div class="w3-container w3-display-left bannerbg">
   <h2 class="w3-container bannertext">Βρες το κατάλληλο                εστιατόριο<br>.....στην κατάλληλη τιμή</h2>
   <button class="w3-btn w3-red w3-round-xxlarge">Βρές Εστιατόριο</button>

 </div>
 </div>
 </div>
 </body>
 </html>

了header.html

  <!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/html1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang:"en">
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato"/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="rules.css"/>
  <title>Αρχική</title>
   <style type="text/css" media="print">
   @page
     {
         size:  auto;   /* auto is the initial value */
         margin: 0mm;  /* this affects the margin in the printer settings       */
     }

   </style>
  </head>
  <body>
    <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="index.php">Δυναμικό Τιμολόγιο</a>
      </div>
      <div class="collapse navbar-collapse" id="myNavbar">
        <ul class="nav navbar-nav navbar-right">
          <li class="active"><a href="index.php">Αρχική</a></li>
          <li><a href="#">Ολα Τα Καταστήματα</a></li>
  <li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
        </ul>
        </div>
    </div>
  </nav>

这是输出的一个截然不同的

enter image description here

我错过了什么?

2 个答案:

答案 0 :(得分:1)

正文在所有浏览器上都有默认边距,因此您需要做的就是将它们删除:

html,
body {
    margin: 0;
    padding:0;
    text-align: center;
}

答案 1 :(得分:1)

默认情况下,大多数浏览器会向正文添加边距/填充。

将以下内容添加到CSS文件的顶部:

html,
body {
    padding: 0;
    margin: 0;
}