我知道這個問題已被問及一百萬次,並有一百萬篇關於它的文章。我嘗試了幾種提供的解決方案,但沒有一個適合我。我只在HTML和CSS上工作了幾個月,所以我現在還不是很好,我希望有人能夠花時間幫助我。CSS Sticky Footer
我創建了一個博客佈局,除了頁腳,一切似乎都正常。我無法讓它留在頁面的底部。現在它正在內容的中間浮動。我想要一個固定在頁面底部的頁腳,並且只有在頁面上的內容很短時纔可見。換句話說,我想要一個像這個網站上的頁腳,而不是我可以使用的位置:fixed。我真的不知道自己做錯了什麼,但就像我說的,我是新手。
下面是我目前使用的代碼,儘管根據各種教程我已經對它進行了很多改變,並且沒有任何功能可以用於我。
此外,由於我是新手,如果您有更多有經驗的人看到與頁腳不相關的東西,我做錯了,我將不勝感激,如果您可以指出,所以我可以學習如何以正確的方式做這件事。
謝謝!
<body>
<div id="outer">
<div id="header">
<div id="wrap">
<div class="logo"><a href="#"><img src="images/logo.png" /></a>
</div><!--end logo div--!>
</div><!--end wrap div--!>
</div><!--end header div--!>
<div id="wrap">
<div id="content">
<div class="featured_title"><a href="#">Example Title One</a></div>
<div class="featured_category"><p>Posted in <a href="#"> News</a></p>
</div><!--end cateogry div--!>
<div class="featured_excerpt">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam
malesuada in orci ornare et porta nisi tristique. Integer sodales feugiat </p>
</div><!--end featured excerpt div--!>
<div class="featured_read">
<p><a href="#">Read More</a></p>
</div><!--end featured_read div--!>
<div id="post_thumbnail">
<img src="images/sample_pic.jpg" />
</div>
<div id="post content">
<div id="post_info">
<div class="post_title">
Example Title Two
</div><!--end post title div--!>
<div class="category">
Posted in <a href="#"> Career Tips</a>
</div>
<div class="post_excerpt">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam malesuad
</p>
</div><!--end post excerpt div--!>
<div class="read_post">
<p><a href="#">Read More</a></p>
</div><!--end read post div--!>
</div><!--end post info div--!>
<div class="divider"><img src ="images/divider.png" /></div>
</div><!--end post content div--!>
<div class="more_stories">
<p><a href="#">Previous Stories</a></p>
</div><!--end more stories div--!>
</div>
</div><!--end content div--!>
</div><!--end wrap div---!>
<div id="wrap">
<div id="sidebar">
<div class="job_search">
<a href=#"><img src="images/job_search.png" /></a>
</div>
<div class="post_job">
<a href="#"><img src="images/post_job.png" /></a>
</div><!--end post_job div--!>
</div><!--end sidebar div--!>
</div><!--end wrap div--!>
</div><!--end outer div--!>
<div id="footer">
</div><!--end footer div--!>
</body>
而CSS
html {height:100%; padding:0; height:100%; }
body { margin: 0 0 40px; background: #f4f4f4; height:100%; }
#wrap { margin: 0 auto; width: 940px; }
/* Header */
#header { width:100%; height: 50px; background: #000; repeat:x; }
.logo { margin-left:380px; }
/* End Header Section */
/*main content section*/
#content { width: 558px; padding: 15px; float:left; position:absolute;
padding-top150px; min-height:100%; }
.featured_title { font-family:Georgia, serif; font-size: 1.7em; color: #4e4e4e; }
.featured_title a { text-decoration:none; color: #4e4e4e; }
.featured_title a:hover { text-decoration:underline; }
.featured_category { font-weight:bold; font-family: Helvetica, sans-serif;
color:#4e4e4e; font-size: 1em; }
.featured_category a{ font-weight:bold; color: #d76186; font-size: 1em;
text-decoration:none; }
.featured_category a:hover { color:#68acc2; }
.featured_excerpt { color:#4e4e4e; font-family:helvetica, sans-serif; font-size:
.9em;}
.featured_read a { font-weight:bold; color:#d76186; font-size: 1em;
text-decoration: none; font-family:helvetica, sans-serif; }
.featured_read a:hover { color:#68acc2; }
.featured_read { border-bottom: 2px solid #4e4e4e; padding-bottom: 5px; }
#post_thumbnail { width:300px; height:200px; padding-top:9px; position:absolute;}
#post_info { position:relative; height:200px; width:248px; left:320px; top:15px; }
.post_title { font-family:georgia, serif; font-size:1.2em; color: #4e4e4e; }
.category { font-weight:bold; color: #4e4e4e; font-size:.8em;
font-family:helvetica, sans-serif; padding-top:3px; }
.category a{ font-weight:bold; color:#d76186; text-decoration:none; }
.category a:hover { color:#68acc2; }
.post_excerpt { color:#4e4e4e; font-family:helvetica, sans-serif; font-size:.8em; }
.read_post a { font-weight:bold; color:#d76186; font-size: .8em;
text-decoration:none; font-family:helvetica, sans-serif; }
.read_post a:hover { color:#68acc2; }
.divider { padding-top:25px; }
.more_stories a{ text-decoration:none; font-family:helvetica; color: #d76186;}
.more_stories a:hover {color: #68acc2;}
/* sidebar */
#sidebar { width:317px; left:20px; top:0; position:relative; float:right;
min-height:100%; }
.job_search { padding-bottom:20px; }
/* Footer */
#footer { clear:both; bottom:0; background:#000; width:100%;
height:35px; margin-top: -100px; position:relative; }
.footer_content { font-family:helvetica, sans-serif; color: #68acc2; }
這對我沒有用。我所做的是刪除#content div中的絕對位置,它似乎工作。我還沒有在IE中測試過它 – libra99