2012-09-13 105 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; 
相关问题