2

我用过这个人指南。

http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page

但是我的页脚只是位于页面的中间,而不是整个页面的宽度。

有人可以帮忙吗。

这是CSS。

body {
background: url(images/topbg.png) repeat-x;
font-family: Arial, Helvetica, sans-serif;
font-size: 17px;
color:#000;
margin:0;
padding:0;
height:100%;
}


h1 {
font-size:100px;
color:#FFF; 
line-height: 10%;
font-family: 'Exo', sans-serif;
}

h2 {
font-size:100px;
color: #18942f; 
line-height: 80%;
font-family: 'Exo', sans-serif;
}

h3 {
font-size: 20px;    
}

.page-container {

width: 960px;
margin-bottom: auto; 
margin-left: auto; 
margin-right: auto;
min-height:100%;
position:relative;

}

.top-nav ul {
margin: 0;
list-style: none;
line-height: normal;
}

.top-nav li {
margin-left: 220px;
}

.top-nav a {
display: block;
float: left;
height: 38px;
margin-right: 1px;
padding: 4px 30px 0 30px;
text-decoration: none;
font-size: 34px;
font-weight: bold;
font-family: 'Exo', sans-serif;
color: #FFF;
}

.top-nav a:hover {
background:  #272727;
color: #18942f;
}

.top-nav .current_page_item a {
background:  #252525;
color: #FFF;
}

#name {
float: left;
margin-top: 70px;
}

#badge {
float:right;
margin-right: 100px;
margin-top: 10px;

}
.info {
clear: both;
padding-bottom:60px;
}

#about {
height: 250px;
width: 300px;
float:left;
}

#about2 {
width: 860px;   
}

#skills {
height: 250px;
width: 300px;
float: left;
text-align: center; 
}

#contact {
height: 250px;
width: 300px;
float: left;
text-align: right;
}

.about3 {
float:left;
width: 500px;   
}
.picture1 {
margin-left: 560px;
padding-top: 25px;
}
.about4 {
width:450px;

}

.footer {

background: url(images/footer.png)repeat-x;
position:absolute;
bottom:0;
width:100%;
height:60px;
}

.footer-links {
font-family:'Exo', sans-serif;
color: #FFF;
font-size:26px;
padding-top: 50px;
text-align:center   
}

这是HTML

<div class="page-container">
<div class="top-nav"> 
  <ul> 
    <li class="current_page_item"><a href="#">Home</a></li> 
    <li><a href="aboutme.html" class="links">About Me</a></li> 
    <li><a href="skills.html" class="links">Skills</a></li> 
    <li><a href="contact.php" class="links">Contact</a></li> 
  </ul> 
</div>
<div id="name"><h1>My</h1>
  <h2>Name</h2></div>
  <div id="badge"><img src="images/webbadge.png" alt="" width="310" height="310" /></div>
  <div class="info">
  <div id = "about"> </div>
   <div id = "skills"> </div>
  <div id = "contact"></div>

<div class ="footer">
<div class ="footer-links">

<a href="#" style="color:#FFF">Home </a> -

<a href="#" style="color:#FFF">About</a> -

<a href="#" style="color:#FFF">#</a> -

<a href="#" style="color:#FFF">#</a>
</div>
</div>
</div>
4

4 回答 4

1
<style>
 .footer
{
   position:fixed;
   bottom:0px;
   z-index:2;
   width:100%;
   padding:5px;
}
</style>

就这么简单?

于 2012-11-03T16:21:54.843 回答
0

这个效果很好,并且已经在多个浏览器上进行了测试。提供基本的 CSS/HTML 以帮助您入门,以及一本不错的手册

http://www.cssstickyfooter.com/

于 2012-11-03T16:25:07.777 回答
0

这应该是:

.footer {
background: url(images/footer.png)repeat-x;
width:100%;
height:60px;
}

或者:

.footer {
background: url(images/footer.png)repeat-x;
position:absolute;
top:{TOP}px;
width:100%;
height:60px;
}

使用 {TOP} 将页脚固定在您想要的位置。

于 2012-11-03T16:27:43.297 回答
0

我对您的代码进行了一些清理,这就是我解决问题的方法:

http://jsfiddle.net/hPWVk/

HTML

    <div class="page-container">

        <div class="top-nav"> 
            <ul> 
                <li class="current_page_item"><a href="#">Home</a></li> 
                <li><a href="aboutme.html" class="links">About Me</a></li> 
                <li><a href="skills.html" class="links">Skills</a></li> 
                <li><a href="contact.php" class="links">Contact</a></li> 
            </ul> 
        </div>

        <div class="content">

            <div id="name">
                <h1>My</h1>
                <h2>Name</h2>
            </div>

            <div id="badge"><img src="images/webbadge.png" alt="" /></div>

            <div class="info">
                <div id = "about"></div>
                <div id = "skills"></div>
                <div id = "contact"></div>

            </div>

        </div>

        <div class ="footer">
            <div class ="footer-links">
                <a href="#" style="color:#FFF">Home </a> -
                <a href="#" style="color:#FFF">About</a> -
                <a href="#" style="color:#FFF">#</a> -
                <a href="#" style="color:#FFF">#</a>
            </div>
        </div>

    </div>

</body>

CSS

body {
background:orange url(images/topbg.png) repeat-x;
font-family: Arial, Helvetica, sans-serif;
font-size: 17px;
color:#000;
margin:0;
padding:0;
height:100%;
}


h1 {
font-size:100px;
color:#FFF; 
line-height: 10%;
font-family: 'Exo', sans-serif;
}

h2 {
font-size:100px;
color: #18942f; 
line-height: 80%;
font-family: 'Exo', sans-serif;
}

h3 {
font-size: 20px;    
}

.page-container {

width: 960px;
margin-bottom: auto; 
margin-left: auto; 
margin-right: auto;
min-height:100%;
position:relative;

}

.top-nav
{
   overflow:hidden; 
}

.top-nav ul {
margin: 0;
list-style: none;
line-height: normal;
}

.top-nav li {
margin-left: 220px;
}

.top-nav a {
display: block;
float: left;
height: 38px;
margin-right: 1px;
padding: 4px 30px 0 30px;
text-decoration: none;
font-size: 34px;
font-weight: bold;
font-family: 'Exo', sans-serif;
color: #FFF;
}

.top-nav a:hover {
background:  #272727;
color: #18942f;
}

.top-nav .current_page_item a {
background:  #252525;
color: #FFF;
}


.content { overflow:hidden; }

#name {
float: left;
margin-top: 70px;
}

#badge {
float:right;
margin-right: 100px;
margin-top: 10px;

}

#badge img { width:50pxl height:50px; }

.info {
overflow:hidden;
padding-bottom:60px;
}

#about {
height: 250px;
width: 300px;
float:left;
}

#about2 {
width: 860px;   
}

#skills {
height: 250px;
width: 300px;
float: left;
text-align: center; 
}

#contact {
height: 250px;
width: 300px;
float: left;
text-align: right;
}

.about3 {
float:left;
width: 500px;   
}
.picture1 {
margin-left: 560px;
padding-top: 25px;
}
.about4 {
width:450px;

}

.footer {

background: url(images/footer.png)repeat-x;
position:fixed;
bottom:60px;
width:100%;
height:60px;
}

.footer-links {
font-family:'Exo', sans-serif;
color: #FFF;
font-size:26px;
padding-top: 50px;
text-align:center   
}​
于 2012-11-03T16:38:13.047 回答