固定页眉和页脚,页脚不是100%

时间:2016-08-25 08:16:54

标签: html css

这里的问题是,当我给页眉和页脚修复时,我无法看到页眉和页脚不是100%。可以任何人解决这个或帮助我。另一件事我需要做这个作为响应,我可以通过使用媒体查询实现这一点。



body {
margin: 0px;
}
#wrapper {
width: 100%;
height: auto;
margin: 0px;
background-color: orange;
}
#header, footer {
width: 100%;
height: 60px;
position: fixed;
}
#header {
top: 0;
}
#footer {
bottom: 0;
}
#navbar {
height: 60px;
width: 100%;
background-color: black;
color: white;
float: left;
overflow: hidden;
}
ul li {
display: block;
position: relative;
padding: 20px 20px;
float: left;
}
ul li a {
color: white;
}
#navbar a:hover {
border-bottom: 3px solid red;
padding: 19px;
}
.active {
background-color: gray;
}
#myCarousel {
background-color: white;
height: 370px;
width: 100%;
float: left;
}
.carousel-inner > .item > img,  .carousel-inner > .item > a > img {
width: 70%;
height: 15%;
margin: auto;
background-color: white;
}
.thumbnail {
height: 300px;
width: 300px;
padding: 25px auto;
margin: 5px;
}
#con {
width: 100%;
height: 300px;
}
.contact {
width: 60%;
height: 300px;
background-color: grey;
padding: 100px 25px;
float: left;
}
.enquiry {
width: 40%;
height: 300px;
background-color: seagreen;
float: left;
padding-left: 5px;
}
input[type=text]:focus {
border: 3px solid red;
}
input[type="text"] {
margin: 0 0 15px 0;
}
#footer {
height: 60px;
width: 100%;
background-color: black;
padding: 10px;
color: white;
float: left;
}
#footer img {
float: right;
margin: 5px;
padding: 5px;
}

<!doctype html>
<html>
<head>
<title>student</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div id="wrapper">
<!--start wrapper-->
<div id="header">
  <div id="navbar"><!--start nav-->
    <ul>
      <li><a class="active" href="home.html">Home</li>
      <li><a href="about.html">About us</li>
      <li><a href="services.html">Services</li>
      <li><a href="products.html">Products</li>
      <li><a href="contact.html">Contact us</li>
    </ul>
  </div>
  <!--end nav--> 
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel"><!--carasel start--> 
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
    <li data-target="#myCarousel" data-slide-to="4"></li>
  </ol>
  
  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active"> <img src="D:\task\photo\h.jpg" alt="Home">
      <div class="carousel-caption">
        <h3>Home</h3>
      </div>
    </div>
    <div class="item"> <img src="D:\task\photo\as.jpg" alt="About us">
      <div class="carousel-caption">
        <h3>About us</h3>
      </div>
    </div>
    <div class="item"> <img src="D:\task\photo\s.jpg" alt="Services">
      <div class="carousel-caption">
        <h3>Services</h3>
      </div>
    </div>
    <div class="item"> <img src="D:\task\photo\p.jpg" alt="Products">
      <div class="carousel-caption">
        <h3>products</h3>
      </div>
    </div>
    <div class="item"> <img src="D:\task\photo\c.jpg" alt="Contact us">
      <div class="carousel-caption">
        <h3>Contact us</h3>
      </div>
    </div>
  </div>
  <!-- Left and right controls --> 
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div>
<!--end carosel-->
<div class="container-fluid text-center bg-grey"><!--boxes-->
  
  <div class="row text-center">
    <div class="col-sm-4">
      <div class="thumbnail"> <img src="D:\task\photo\i.jpg" alt="Innovation">
        <p><strong>Innovation</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail"> <img src="D:\task\photo\cr.png" alt="Creative">
        <p><strong>Creativity</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail"> <img src="D:\task\photo\po.jpg" alt="Positive">
        <p><strong>Positivity</strong></p>
      </div>
    </div>
  </div>
  <!--end boxes-->
  <div id="con">
    <div class="contact">
      <h1>Address</h1>
      <p><span class="glyphicon glyphicon-map-marker"></span> Abc private limited
        no54,2ndstreet,
        madipakkam,
        chennai-67. </p>
      <p><span class="glyphicon glyphicon-envelope"></span> ABCPVT@gmail.com</p>
    </div>
    <div class="enquiry">
      <h1>Enquiry Form</h1>
      <table border="0" align="center">
        <form name="form" action="email.php" id="form" method="post">
          <tr>
          <tr>
            <td>Name</td>
            <td><input name="name" placeholder="Name" type="text" value=""></td>
          </tr>
          <
          <tr>
            <td>Email</td>
            <td><input name="email" placeholder="Email" type="text" value=""></td>
          </tr>
          <tr>
            <td>Phone</td>
            <td><input name="phone" placeholder="phonenumber" type="text" value=""></td>
          </tr>
          <tr>
            <td>Message</td>
            <td><textarea name="msg" placeholder="Type your text here..."></textarea></td>
          </tr>
          <td colspan="2" style="text-align:center"><input id="send" name="submit" type="submit" value="Submit"></td>
          </tr>
          
        </form>
      </table>
    </div>
  </div>
  <div id="footer"> copyrights &copy; to WWW.abcpvt.com <img src="E:\photos\fb.png" alt="fb"/> <img src="E:\photos\ln.png" alt="tweet"/> <img src="E:\photos\tw.png" alt="linkedin"/> </div>
</div>
<!--end wrapper-->
</body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

您忘记了主题标签(#)symobol,以div代替id="footer"代替footer代码(您不使用)。您应该添加left: 0;(否则左侧位置将从父级继承)。请参阅下面的更新snuppet。

&#13;
&#13;
body
{
margin:0px;
}
#wrapper
{
width:100%;
height:auto;	
margin:0px;
background-color:orange;
}
#header,#footer
{
width:100%;
height:60px;
position:fixed;
}
#header
{
top:0;  
}
#footer
{
  left:0;
bottom:0; 
}
#navbar
{
height:60px;
width:100%;
background-color:black;
color:white;
float:left;
overflow: hidden;

}

 ul li
{
display: block;
position: relative;
padding:20px 20px;
float:left;
}
ul li a
{
color:white;
}
#navbar a:hover
{
	border-bottom:3px solid red;
	padding:19px;
}
.active
{
background-color:gray;
}
#myCarousel
{
background-color:white;
height:370px;
width:100%;
float:left;
}
.carousel-inner > .item > img,
  .carousel-inner > .item > a > img 
  {
      width: 70%;
      height:15%;
      margin: auto;
      background-color:white;
  }



.thumbnail
{
height:300px;
width:300px;
padding:25px auto;
margin:5px;

}
#con
{
width:100%;
height:300px;
}
.contact
{
width:60%;
height:300px;
background-color:grey;
padding:100px 25px;
float:left;
}

.enquiry
{
width:40%;
height:300px;
background-color:seagreen;
float:left;
padding-left:5px;	
}
input[type=text]:focus {
    border: 3px solid red;
}
input[type="text"] 
{
	margin: 0 0 15px 0;
}


#footer
{
height:60px;
width:100%;
background-color:black;
padding:10px;
color:white;
float:left;
}
#footer img
{
float:right;
margin:5px;
padding:5px;

}
&#13;
<!doctype html>
<html>
<head>
<title>student</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div id="wrapper"><!--start wrapper-->
<div id="header">
<div id="navbar"><!--start nav-->
<ul>
<li><a class="active" href="home.html">Home</li>
<li><a href="about.html">About us</li>
<li><a href="services.html">Services</li>
<li><a href="products.html">Products</li>
<li><a href="contact.html">Contact us</li>
</ul>
</div><!--end nav-->
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel"><!--carasel start-->
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
    <li data-target="#myCarousel" data-slide-to="4"></li>

  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="D:\task\photo\h.jpg" alt="Home">
      <div class="carousel-caption">
        <h3>Home</h3>
              </div>
    </div>

    <div class="item">
      <img src="D:\task\photo\as.jpg" alt="About us">
      <div class="carousel-caption">
        <h3>About us</h3>
             </div>
    </div>

    
    <div class="item">
      <img src="D:\task\photo\s.jpg" alt="Services">
      <div class="carousel-caption">
        <h3>Services</h3>
             </div>
    </div>
    <div class="item">
      <img src="D:\task\photo\p.jpg" alt="Products"> 
      <div class="carousel-caption">
        <h3>products</h3>
             </div>
    </div>
    <div class="item">
      <img src="D:\task\photo\c.jpg" alt="Contact us">
      <div class="carousel-caption">
        <h3>Contact us</h3>
             </div>
    </div>
  
  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div><!--end carosel-->

<div class="container-fluid text-center bg-grey"><!--boxes-->
  
  <div class="row text-center">
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\i.jpg" alt="Innovation">
        <p><strong>Innovation</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\cr.png" alt="Creative">
        <p><strong>Creativity</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\po.jpg" alt="Positive">
        <p><strong>Positivity</strong></p>
              </div>
    </div>
</div><!--end boxes-->


<div id="con">
<div class="contact">
<h1>Address</h1>
<p><span class="glyphicon glyphicon-map-marker"></span>
Abc private limited
no54,2ndstreet,
madipakkam,
chennai-67.
</p>
 <p><span class="glyphicon glyphicon-envelope"></span> ABCPVT@gmail.com</p>
</div>
<div class="enquiry">
<h1>Enquiry Form</h1>
<table border="0" align="center">
<form name="form" action="email.php" id="form" method="post">
<tr>
<tr>
<td>Name</td>
<td><input name="name" placeholder="Name" type="text" value=""></td>
</tr>

<<tr>
<td>Email</td>
<td><input name="email" placeholder="Email" type="text" value=""></td>
</tr>

<tr>
<td>Phone</td>
<td><input name="phone" placeholder="phonenumber" type="text" value=""></td>
</tr>

<tr>
<td>Message</td>
<td><textarea name="msg" placeholder="Type your text here..."></textarea></td>
</tr>
<td colspan="2" style="text-align:center"><input id="send" name="submit" type="submit" value="Submit"></td>
</tr>
</form>
</table>

</div>
</div>
<div id="footer">
copyrights &copy; to WWW.abcpvt.com
<img src="E:\photos\fb.png" alt="fb"/>
<img src="E:\photos\ln.png" alt="tweet"/>
<img src="E:\photos\tw.png" alt="linkedin"/>
</div>








</div><!--end wrapper-->
</body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

您正在使用bootstrap

Use this <div class="navbar-inverse navbar-fixed-top"> insted of <div id="header">

无需为此

添加任何样式

body
{
margin:0px;
}
#wrapper
{
width:100%;
height:auto;	
margin:0px;
background-color:orange;
}
#header,footer
{
width:100%;
height:60px;
position:fixed;
}
#header
{
top:0;  
}
#footer
{
bottom:0; 
}
#navbar
{
height:60px;
width:100%;
background-color:black;
color:white;
float:left;
overflow: hidden;

}

 ul li
{
display: block;
position: relative;
padding:20px 20px;
float:left;
}
ul li a
{
color:white;
}
#navbar a:hover
{
	border-bottom:3px solid red;
	padding:19px;
}
.active
{
background-color:gray;
}
#myCarousel
{
background-color:white;
height:370px;
width:100%;
float:left;
}
.carousel-inner > .item > img,
  .carousel-inner > .item > a > img 
  {
      width: 70%;
      height:15%;
      margin: auto;
      background-color:white;
  }



.thumbnail
{
height:300px;
width:300px;
padding:25px auto;
margin:5px;

}
#con
{
width:100%;
height:300px;
}
.contact
{
width:60%;
height:300px;
background-color:grey;
padding:100px 25px;
float:left;
}

.enquiry
{
width:40%;
height:300px;
background-color:seagreen;
float:left;
padding-left:5px;	
}
input[type=text]:focus {
    border: 3px solid red;
}
input[type="text"] 
{
	margin: 0 0 15px 0;
}


#footer
{
height:60px;
width:100%;
background-color:black;
padding:10px;
color:white;
float:left;
}
#footer img
{
float:right;
margin:5px;
padding:5px;

}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div id="wrapper"><!--start wrapper-->
<div class="navbar-inverse navbar-fixed-top">
<div id="navbar"><!--start nav-->
<ul>
<li><a class="active" href="home.html">Home</li>
<li><a href="about.html">About us</li>
<li><a href="services.html">Services</li>
<li><a href="products.html">Products</li>
<li><a href="contact.html">Contact us</li>
</ul>
</div><!--end nav-->
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel"><!--carasel start-->
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
    <li data-target="#myCarousel" data-slide-to="4"></li>

  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="D:\task\photo\h.jpg" alt="Home">
      <div class="carousel-caption">
        <h3>Home</h3>
              </div>
    </div>

    <div class="item">
      <img src="D:\task\photo\as.jpg" alt="About us">
      <div class="carousel-caption">
        <h3>About us</h3>
             </div>
    </div>

    
    <div class="item">
      <img src="D:\task\photo\s.jpg" alt="Services">
      <div class="carousel-caption">
        <h3>Services</h3>
             </div>
    </div>
    <div class="item">
      <img src="D:\task\photo\p.jpg" alt="Products"> 
      <div class="carousel-caption">
        <h3>products</h3>
             </div>
    </div>
    <div class="item">
      <img src="D:\task\photo\c.jpg" alt="Contact us">
      <div class="carousel-caption">
        <h3>Contact us</h3>
             </div>
    </div>
  
  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div><!--end carosel-->

<div class="container-fluid text-center bg-grey"><!--boxes-->
  
  <div class="row text-center">
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\i.jpg" alt="Innovation">
        <p><strong>Innovation</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\cr.png" alt="Creative">
        <p><strong>Creativity</strong></p>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="thumbnail">
        <img src="D:\task\photo\po.jpg" alt="Positive">
        <p><strong>Positivity</strong></p>
              </div>
    </div>
</div><!--end boxes-->


<div id="con">
<div class="contact">
<h1>Address</h1>
<p><span class="glyphicon glyphicon-map-marker"></span>
Abc private limited
no54,2ndstreet,
madipakkam,
chennai-67.
</p>
 <p><span class="glyphicon glyphicon-envelope"></span> ABCPVT@gmail.com</p>
</div>
<div class="enquiry">
<h1>Enquiry Form</h1>
<table border="0" align="center">
<form name="form" action="email.php" id="form" method="post">
<tr>
<tr>
<td>Name</td>
<td><input name="name" placeholder="Name" type="text" value=""></td>
</tr>

<<tr>
<td>Email</td>
<td><input name="email" placeholder="Email" type="text" value=""></td>
</tr>

<tr>
<td>Phone</td>
<td><input name="phone" placeholder="phonenumber" type="text" value=""></td>
</tr>

<tr>
<td>Message</td>
<td><textarea name="msg" placeholder="Type your text here..."></textarea></td>
</tr>
<td colspan="2" style="text-align:center"><input id="send" name="submit" type="submit" value="Submit"></td>
</tr>
</form>
</table>

</div>
</div>
<div id="footer">
copyrights &copy; to WWW.abcpvt.com
<img src="E:\photos\fb.png" alt="fb"/>
<img src="E:\photos\ln.png" alt="tweet"/>
<img src="E:\photos\tw.png" alt="linkedin"/>
</div>








</div><!--end wrapper-->