2013-09-21 43 views
-1

我想重新設計我的網站使用div的(早些時候它是使用表設計的)。我面臨的一個問題是,容器背景僅限於頁面的不透明,儘管所有內容都放在容器div中。另外,如果我將任何內容放在「內容」div中,「rightsidebar」將滑入「content」div的底部。請幫助解決這兩個問題。容器背景不覆蓋整個屏幕

我homepage.php代碼:

<body> 
<div class="container"> 
    <?php 
    include "header1.php" 
    ?> 
     <div class="sidebarleft"><font class="common"> 
     <ul> 
     <li style="font-weight:bold; font-size:26; align:center;">Categories</li> 
     <li style="font-size:26;"><a href="pol_score_reset.php">Politics</a></li> 
     <li style="font-size:26;"><a href="ps_score_reset.php">Programming Skills</a></li> 
     <li style="font-size:26;"><a href="gk_score_reset.php">general knowledge</a></li> 
     </ul></font> 
     </div> 



     <div class="sidebarright"><font class="common"> 
     <--Google Adsense Ad--> 
     </font> 
     </div> 

</div> 
</body> 

header1.php:

<div class="header"> 
<a href="homepage.php"><img class="logo" src="images/logo.png"/></a> 
    <div style="width:728px; height:20; float:right; margin-top:20px; margin-right:10px;"> 
    <-- Google AdSense Ad--> 

    </div> 
<br/> 
    <table width="100%" border="10"> 
     <tr> 
      <td width="16.7%"><a href="homepage.php"><em>Home</em></a></td> 
      <td width="16.7%"><a href="aboutus.php?us">About us</a></td> 
      <td width="16.7%"><a href="contactus.php?us">Contact us</a></td> 
      <td width="16.7%"><a href="privacy policy.php?us">Privacy policy</a></td> 
      <td width="16.7%"><a href="user_cp.php">Past Quizzes</a></td> 
      <td width="16.7%"><a href="logout.php">Logout</a></td> 
     </tr> 
    </table> 
</div> 
<br /> 

樣式表:

body 
    { 
    height:100%; 
    background-image:url(images/background.jpg); 
    background-position: top left; 
    background-attachment: fixed; 
    } 
     div.header{ 
     width:100%; 
     } 
     div.container{ 
     width:80%; 
     height:100%; 
     margin-left:10%; 
     margin-right:10%; 
     background:gray; 
     display:block; 
     } 
     div.sidebarleft{ 
     width:20%; 
     float:left; 
     } 
     div.contentmain{ 
     width:75%; 
     float:left; 
     } 
     div.sidebarright{ 
     width:20%; 
     float:right; 
} 
+1

你能否提供[小提琴](http://jsfiddle.net)。我懷疑你需要在CSS清除之後放置一個新的div,這可以解決你的問題。 – Martyn0627

+0

我不善於使用Javascript,也不能提供小提琴。你能多解釋一下嗎?我還包括一個鏈接到頁面。檢查它。 –

+0

試試'body {background:url(images/background.jpg); background-size:cover;'並且確保你的背景圖像足夠大以覆蓋整個屏幕,或者使用一些漂亮的圖案;) – mdesdev

回答

0

更改HTML到:

<body> 
<div class="container"> 
    <?php 
    include "header1.php" 
    ?> 
     <div class="sidebarleft"><font class="common"> 
     <ul> 
     <li style="font-weight:bold; font-size:26; align:center;">Categories</li> 
     <li style="font-size:26;"><a href="pol_score_reset.php">Politics</a></li> 
     <li style="font-size:26;"><a href="ps_score_reset.php">Programming Skills</a></li> 
     <li style="font-size:26;"><a href="gk_score_reset.php">general knowledge</a></li> 
     </ul></font> 
     </div> 



     <div class="sidebarright"><font class="common"> 
     <--Google Adsense Ad--> 
     </font> 
     </div> 
     <div class="clearfix"></div> 

</div> 
</body> 

,並加入到你的CSS以下樣式:

.clearfix{ 
    clear: both; 
} 

這種簡單的使包含div蓋你已經離開浮動這些div。

+0

它的工作..謝謝你..你能爲我的另一個問題提出一個解決方案嗎? –