2011-01-19 87 views
2

我想爲我的網站的頂部和底部做單獨的背景圖像。在做了一些研究之後,我發現我需要製作包裝和放置內容。我已經做了這麼多,背景工作,除了底部的定位。底部背景似乎有一個固定的位置,而不是達到絕對底部。這是我迄今爲止的代碼,預先感謝您能給我提供的任何幫助。如何在網站的頂部和底部製作單獨的背景圖片?

CSS

body { 
background-color: #0b0e13; 
padding: 0px; 
margin: 0px; 
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; 
font-size: 12px; 
color: #717e8e; 
} 
.accentbar { 
color: #2d3a4a; 
} 
#header { 
height: 200px; 
width: 960px; 
margin-right: auto; 
margin-left: auto; 
padding: 0px; 
margin-top: 0px; 
margin-bottom: 0px; 
} 
#content { 
height: 600px; 
width: 960px; 
margin-right: auto; 
margin-left: auto; 
} 
#footer { 
width: 960px; 
margin-top: auto; 
margin-right: auto; 
margin-left: auto; 
text-align: center; 
padding: 0px; 
margin-bottom: 0px; 
} 
#footer .text { 
color: #5a6470; 
} 
#headbar { 
height: 35px; 
width: 960px; 
padding: 0px; 
margin: 0px; 
} 
#logo { 
background-image: url(/img/logo.jpg); 
height: 55px; 
background-repeat: no-repeat; 
background-position: center bottom; 
width: 350px; 
margin: 0px; 
float: left; 
padding-top: 37px; 
padding-right: 0px; 
padding-bottom: 0px; 
padding-left: 0px; 
} 

#navbar { 
height: 65px; 
width: 610px; 
float: right; 
background-repeat: no-repeat; 
padding-top: 35px; 
padding-right: 0px; 
padding-bottom: 0px; 
padding-left: 0px; 
} 

#wraptop { 
width: 1200px; 
height: 100%; 
padding: 0; 
background-image: url(/img/backs/bg_t.jpg); 
background-repeat: no-repeat; 
background-position: center top; 
margin-top: 0; 
margin-right: auto; 
margin-bottom: 0; 
margin-left: auto; 
} 
#wrapbot { 
width: 1200px; 
height: 100%; 
padding: 0; 
background-image: url(/img/backs/bg_b.jpg); 
background-repeat: no-repeat; 
background-position: center bottom; 
margin-top: 0; 
margin-right: auto; 
margin-bottom: 0; 
margin-left: auto; 
} 

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>Arbiters of Light</title> 
<link href="/css/styles.css" rel="stylesheet" type="text/css" /> 
<style type="text/css"> 
</style> 
</head> 

<body> 
<div id="wraptop"> 
<div id="wrapbot"> 
    <div class="header" id="header"> 
    <div class="headbar" id="headbar">Content for class "headbar" id "headbar" Goes Here</div> 
    <div id="logo"></div> 
    <div id="navbar">  
    <img src="/img/nav/abo.jpg" alt="about" width="82" height="60" hspace="0" border="0" /><img src="/img/nav/cha.jpg" alt="charter" width="86" height="60" hspace="0" border="0" /><img src="/img/nav/com.jpg" alt="community" width="97" height="60" hspace="0" border="0" /><img src="/img/nav/for.jpg" alt="forums" width="81" height="60" border="0" /><img src="/img/nav/gal.jpg" alt="gallery" width="78" height="60" border="0" /><img src="/img/nav/res.jpg" alt="resources" width="106" height="60" border="0" /><img src="/img/nav/app.jpg" alt="apply" width="80" height="60" border="0" /> 
    </div> 
    </div><!-- end header --> 
    <div class="content" id="content"> 
    </div><!-- end content --> 
    <div class="footer" id="footer"> 
    <p>PRIVACY - TERMS OF SERVICE - CONTACT - DISCLAIMER<br /></p> 
    <p class="text">© 2011 ARBITERS OF LIGHT</p> 
    </div><!-- end footer --> 
</div> 
</div> 
</body> 

+0

將有助於如果圖像是在網上看到他們是如何定位在頁面 – Sotiris 2011-01-19 16:21:55

回答

0

抱歉,但你爲什麼用你的包頂裏面你wrapbot,不是它只是爲了更好地擁有的結尾低於DIV包裹頂部的div,這可能會解決問題,實際上我通常只是在最後放置一個Z-index的圖像而不是任何我想要的圖像。這通常運作良好

0

您需要將wrapbot div放在頁面/代碼的底部,而不是其他任何div的內部。同時,使該wrapbot DIV位置絕對和像你這樣的位置底部中心循環X

#wraptop { 
width: 1200px; 
height: 100%; 
padding: 0; 
background-image: url(/img/backs/bg_t.jpg); 
position: absolute; 
background-repeat: x; 
background-position: center top; 
margin-top: 0; 
margin-right: auto; 
margin-bottom: 0; 
margin-left: auto; 
z-index:1; 
} 
#wrapbot { 
width: 1200px; 
height: 100%; 
padding: 0; 
background-image: url(/img/backs/bg_b.jpg); 
position:absolute; 
background-repeat: x; 
background-position: center bottom; 
margin-top: 0; 
margin-right: auto; 
margin-bottom: 0; 
margin-left: auto; 
z-index:1; 
} 

的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>Arbiters of Light</title> 
<link href="/css/styles.css" rel="stylesheet" type="text/css" /> 
<style type="text/css"> 
</style> 
</head> 

<body> 
<div id="wraptop"> 
</div> 

    <div class="header" id="header"> 
    <div class="headbar" id="headbar">Content for class "headbar" id "headbar" Goes Here</div> 
    <div id="logo"></div> 
    <div id="navbar">  
    <img src="/img/nav/abo.jpg" alt="about" width="82" height="60" hspace="0" border="0" /><img src="/img/nav/cha.jpg" alt="charter" width="86" height="60" hspace="0" border="0" /><img src="/img/nav/com.jpg" alt="community" width="97" height="60" hspace="0" border="0" /><img src="/img/nav/for.jpg" alt="forums" width="81" height="60" border="0" /><img src="/img/nav/gal.jpg" alt="gallery" width="78" height="60" border="0" /><img src="/img/nav/res.jpg" alt="resources" width="106" height="60" border="0" /><img src="/img/nav/app.jpg" alt="apply" width="80" height="60" border="0" /> 
    </div> 
    </div><!-- end header --> 
    <div class="content" id="content"> 
    </div><!-- end content --> 
    <div class="footer" id="footer"> 
    <p>PRIVACY - TERMS OF SERVICE - CONTACT - DISCLAIMER<br /></p> 
    <p class="text">© 2011 ARBITERS OF LIGHT</p> 
    </div><!-- end footer --> 


<div id="wrapbot"> 
</div> 
</body> 

我真的wouldnt甚至給他們打電話wraptop,他們並不需要因任何原因換行。 div bgtop和bgbottom可能會更好。

1

嘗試CSS3 multibackground:

body { 
    background: url(/img/backs/bg_t.jpg) no-repeat center top, 
    url(/img/backs/bg_b.jpg) no-repeat center bottom; /* second backgrond */ 
} 
+0

我用這一個突出的菜單。我希望ie9有一些簡單的東西 – crh225 2013-03-26 21:25:38

相關問題