2014-06-07 80 views
0

我有一個頁腳div,它只是一個純色,我想坐在我的容器DIV的外部,它被稱爲'mainhome'。我希望它能夠延伸整個網站。它只是坐在我的旗幟之上 - 我現在迷失在代碼中,所以也許我錯過了一些小小的東西?我的頁腳DIV不會坐在我的頁面底部

預先感謝您

我的HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 
<link href="style.css" rel="stylesheet" type="text/css" /> 

</head> 

<body> 
<div class="mainhome"> 
    <div class="header"> 
     <div class="menubutton-leftside" style="margin-right:23px"><h2>home</h2></div> 
     <div class="menubutton-leftside" style="margin-right:20px"><h2>about</h2></div> 
     <div class="menubutton-leftside" style="margin-right:30px"><h2>portfolio</h2></div> 
     <div class="menubutton-leftside" style="margin-right:27px"><h2>contact</h2></div> 
     <div class="logo"><img src="images/es-logo.png" width="170" height="170" /></div> 
     <div class="menubutton-rightside" style="margin-left:17px"><h2>print</h2></div> 
     <div class="menubutton-rightside" style="margin-left:25px"><h2>digital</h2></div> 
     <div class="menubutton-rightside" style="margin-left:38px"><h2>illustration</h2></div> 
     <div class="menubutton-rightside" style="margin-left:20px"><h2>brand</h2></div> 
    </div> 
     <div class="mainimage"> 
     <div id="slider_container"> 
    <div id="slides"> 
       <img src="images/slider/emmasteed.png" alt="Emma Steed Graphic Art and Web Design" /> 
       <img src="images/slider/graphicdesign-desk.png" alt="Emma Steed Graphic Art and Web Design" /> 
    </div> 
</div> 

    <div class="bluebar"></div> 
     <div class="largemenubutton" style="margin-right:36px"><img src="images/portfolio.png" /></div> 
     <div class="largemenubutton" style="margin-right:36px"><img src="images/getintouch.png" /></div> 
     <div class="largemenubutton"><img src="images/aboutme.png" /></div> 
     </div></div> 
     <div class="footer"></div> 
</body> 
</html> 

我的CSS

@charset "UTF-8"; 
/* CSS Document */ 

body { 
    background-image:url(images/header-background.png); 
    background-repeat:repeat-x; 
    margin:0; 
    padding:0; 
} 

.mainhome { 
    width: 855px; 
    margin-top: 0; 
    margin-right: auto; 
    margin-bottom: 0; 
    margin-left: auto; 
} 

.header { 
    height: 236px; 
    background-image:url(images/header-background.png); 
    background-repeat:repeat-x; 
    clear:left; 
} 

.mainimage { 
    width: 855px; 
    height: 423px; 
    background-color:#0C9; 
    position:absolute; 
    top:220px; 
    float:left; 
    z-index:-1; 
} 

#slider_container { 
     width:855px; 
     height:423px; 
     overflow:hidden; 
} 

.bluebar { 
    width: 855px; 
    height: 16px; 
    background-color:#334d5c; 
    clear:left; 
    float:left; 
} 

.menubutton-leftside { 
    width:60px; 
    height:20px; 
    float:left; 
    margin-top:95px; 
} 

.menubutton-rightside { 
    width:60px; 
    height:20px; 
    float:left; 
    margin-top:95px; 
    text-align:right; 
} 

h2 { 
    font-family:Tahoma, Geneva, sans-serif; 
    font-size:12px; 
    font-weight:normal; 
    color:#666; 
    display:inline; 
} 

.logo { 
    width:170px; 
    height:170px; 
    float:left; 
    margin-top:30px; 
} 

.largemenubutton { 
    width:261px; 
    height:259px; 
    float:left; 
    margin-top:20px; 
} 

.footer { 
    width:100%; 
    height: 61px; 
    background-color:#334d5c; 
    clear:left; 
} 

回答

0

它看起來並不像.nameimage需要被絕對定位,但它取決於你希望它能做到。粗糙的例子:http://codepen.io/anon/pen/oAbJy

+0

我有這個absalutely定位,因爲我有它只是重疊的標題,因爲這有一個陰影(http:// www。 emmasteed.co.uk/Site.jpg)是否消除了使頁腳坐下的缺陷? – user3714234

+0

是的,刪除絕對將'.mainimage'放回到文檔流中,以便頁腳停留在它下面。要重新獲得重疊,請在'.mainimage'上嘗試一個負邊距,例如:http://codepen.io/anon/pen/DjuCE。 請記住這只是將腳註放在'.mainimage'下面。如果'.mainimage'或'#slider_container'中的內容高度動態變化,則頁腳會向上或向下移動以保持在其下方。我最喜歡的網站了解這種事情的不同方法是http://learnlayout.com。 – thebenedict

0

可能是最容易做的事情,如果你總是希望它處於最底層只是給它一個固定的位置。將以下內容添加到頁腳的CSS中。 (你也可能必須在身上設置高度和寬度爲100%)

position: Absolute; 
bottom: 0px; 
+0

謝謝 - 閱讀完本文後,我確實認爲'當然可以!'然而在Dreamweaver中它仍然位於我的'mainimage'之上,並且在瀏覽器中,它現在位於底部的圖像上,而不是在底部。 我現在有我的頁腳: .footer { \t height:61px; \t寬度:100%; \t background-color:#334d5c; \t position:absolute; \t bottom:0px; } HTML:

user3714234

+0

試圖在此之後 - 這是不理想的我想要的東西,就好像屏幕尺寸更小,我可以看到這是爲什麼現在坐在我上面的其他圖片我只是想這個坐在如果這是有道理的,我的網頁的底部並不總是可見的。 – user3714234

+0

你好,最後一件事,讓你100%確定你的html和你的身體在css中設置了100%的高度和100%的寬度,否則body或html頁面實際上不會伸展到這一頁。 – Ethan