2012-09-13 35 views
2

我無法使自動高度適用於FF或Chrome。它在IE中運行良好,但在FF和Chrome中,它基本上使div的高度與頁面本身一樣高,即使內容不能填充該元素。它只會在實際內容下留下巨大的空白區域。自動高度在FF和Chrome中不起作用

<center> 
    <div id = "choosearea"> 
     <div id = "logbar"> 
      <div id = "logbartext">Choose Your Area 
      </div> 
     <div id = "log"> 
      <a href = "?action=home">Home</a> 
      <a href = "?action=logout&NOHEADERS=1">Log Out</a> 
     </div> 
    </div> 
    <div id = "header"> 
     <div id = "ss_logo"> 
      <img src="http://i1157.photobucket.com/albums/p595/Gamethefirst/ssnewbanner1.png"> 
     </div> 
     <div id = "area">Serving:<br><u>SouthWest Ohio<br>Northern Kentucky<br>SouthEast Indiana</u> 
     </div> 
    </div> 
<center> 
    <div id = "menu"> 
    </div> 
</center> 
    <div width = "100%" align = "center"> 
     <div id = "paddingbox"> 
     <div id = "chooseareatext"> 
      <p>Choose the area which you reside from the options below in order to post/view your ad.</p> 
      <ul class = "bullets"> 
      <li><a href = "?board=swohio">SouthWest Ohio</a></li> 
      <li><a href = "?board=nk">Northern Kentucky</a></li> 
      <li><a href = "?board=indi">SouthEast Indiana</a></li> 
      </ul> 
     </div> 
     <div id = "affs"> 
      <h3>Need Supplies? Get Great Deals From Our Friends!</h3> 
     </div> 
     </div> 
    </div> 
    </div> 
</center> 

樣式表

#choosearea { 
    height: auto; 
} 

下面是一個例子: http://skillswap.boards.net/index.cgi?board=postad

+0

凹凸..如果我大聲 –

+0

對於任何未來的問題,嘗試使用問題上的標籤來表示問題所在的技術。我懷疑大多數人沒有看到問題,因爲唯一的標籤是'auto',而不是'css' – andyb

回答

1

CSS height默認值是auto#paddingbox上的height:100%導致<div>很長,在FF和Chrome上創建了大量的空白區域。刪除應該解決問題。

此外,您示例中的某些標記無效或在較新版本的HTML規範中不推薦使用。

例如width="100%"不是有效的屬性。要應用內嵌樣式,正確的語法是<div style="width:100%">

<center>標籤和align="center"屬性也已經因爲HTML 4.01棄用,在HTML 5中,而不是推薦的方法是使用CSS來表象方面的增加不存在例如,margin:0 autotext-align:center的標記。有關詳細信息,請參閱Why is the <center> tag deprecated in HTML?。既然已經存在問題的樣式表,它可能有助於separatr內容(HTML)和演示(CSS) - http://www.alistapart.com/articles/separationdilemma/

0

寫這篇文章的車身風格:

position: absolute; 
相關問題