height:auto firefox解決方案

做一個網頁。就會遇見firefox與iE css的兼容問題
今天俺就發現了。
父div 設置了height:auto 在IE中設置沒問題,但是到firefox中父div卻沒有增加,,,
看網上說 加入 min-height:10px; height:auto !important 但是該設置在子div出現float的時候還是不行。原因貌似是 當auto計算的是非float類型的高度。所以。。。。。
沒辦法設置爲 height:100% overflow:auto 這樣就可以。不清楚回家看看詳細。。。。

還有就是css太噁心了。就是一箇中文符號讓俺找了半天。。。暈。。。。

補充內容:
至於上面的解決方法能解決暫時的問題,但是看邏輯或者其他東西暫時看不懂,又請教了一下。 對此div修改一下

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
.clear { clear:both; margin:0px; top:0px}
</style>
<title>Just a test</title>

</head>
<body>
<center>


<!-- mainLogo begin -->
<div class="mainlogo">
mainlogo
</div>
<!-- mainLogo end-->

<!-- mainBody begin -->
<div class="mainBody">


<!-- mainBodyLeft begin-->
<div class="mainBodyLeft">

</div>
<!-- mainBodyLeft end-->

<!-- mainBodyRight begin-->
<div class="mainBodyRight">
this is the right
</div>
<!-- mainBodyRight end-->


// 注意這裏是解決的辦法。加入一個clear div clear定義在上面
<div class="clear"></div>
</div>
<!-- mainBody end-->

</center>

</body>
</html>


對與clear屬性的說明:
clear:該屬性的值指出了不允許有浮動對象的邊。

這個屬性是用來控制float屬性在文檔流的物理位置的。

當屬性設置float(浮動)時,他所在的物理位置已經脫離文檔流了,但是大多時候我們希望文檔流能識別float(浮動),或者是希望float(浮動)後面的元素不被float(浮動)所影響,這個時候我們就需要用clear:both;來清除clear:both;

這個解釋和可以。而且理解也可以呵呵、。就是他了、、、、當初看auto的時候裏面也提到了
不認識別設置float屬性的 div這樣就解決了。。。。。
希望能給大家一小點點幫助呵呵 以後不必爲float 屬性發愁了呵呵。。。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章