国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

關于clearBoth在GOOGLE Chrome中的問題解決方法

2024-07-11 08:29:22
字體:
來源:轉載
供稿:網友
下面這段CSS在IE中好好的,但在GOOGLE Chrome中總是不行,我調測了無數次。問題就出在 clearBoth 這個樣式上,本來這個樣式是做為換行用的清除DIV浮動狀態的樣式,在IE7中正常,但在GOOGLE Chrome卻空出很大一塊,不知道是什么原因?
代碼如下:

復制代碼
代碼如下:
<html>
<head>
<style>
.userInfo
{
width: 430px;
height: 300px;
border: 1px solid #eee;
float: left;
}
.chartPanel
{
border: 1px solid #eee;
height: 300px;
margin: 0 0 0 440px;
}
.clearBoth
{
clear: both;
}
</style>
</head>
<body>
<div class="userInfo">
</div>
<div class="chartPanel">
<div style="float: left;">
sasadf</div>
<div class="clearBoth">
</div>
<div style="float: left;">
sasabbbbbbbbbbbbbbbbbbbbbdf</div>
</div>
<div class="clearBoth">
</div>
<div class="userInfo">
</div>
<div class="chartPanel">
<div style="float: left; height: 40px; background: red;">
aaa</div>
<div style="float: left; height: 40px; background: blue;">
bbbbbbbbbbbbb</div>
<div class="clearBoth">
</div>
<div style="float: left; height: 40px; background: yellow;">
aaa</div>
<div style="float: left; height: 40px; background: green;">
bbbbbbbbbbbbb</div>
</div>
</body>
</html>

如下的樣式:

復制代碼
代碼如下:
.chartPanel
{
border: 1px solid #eee;
height: 300px;
margin: 0 0 0 440px;
float:left;
}

上面的樣式加上float:left;就可以解決這個問題,但需要請調整margin的數值到所需要的值,它是以它左邊的那個userinfo為參考點,多個元素在一行應該都要定義float排列在一行,同一行的那兩個div應該用一個大的div包起來,還有就是如果要換行,直接對需要換行的元素定義clear:both;就好了,沒必要加一個
這樣的元素在那,有時候我們加這個元素是為撐開兼容才用的。
詳解代碼如下:

復制代碼
代碼如下:
<!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>
<title></title>
<style type="text/css">
.userInfo
{
width: 430px;
height: 300px;
border: 1px solid #eee;
position:absolute;
left:0;
top:0;
}
.chartPanel
{
border: 1px solid #eee;
height: 300px;
margin: 0 0 0 440px;
}
.clearBoth
{
clear: both;
}
.outbox{clear:both; float:left; width:100%; position:relative;margin-bottom:10px; }
.red{ float:left;height:40px; background:red;}
.blue{ float:left;height:40px; background:blue;}
.yellow{float:left; height:40px; background:yellow;}
.green{ float:left;height: 40px; background:green;}
</style>
</head>
<body>
<div class="outbox">
<div class="userInfo">
</div>
<div class="chartPanel">
<div>
sasadf
</div>
<div class="clearBoth">
sasabbbbbbbbbbbbbbbbbbbbbdf
</div>
</div>
</div>
<div class="outbox">
<div class="userInfo">
</div>
<div class="chartPanel">
<div class="clearBoth">
<div class="red">
aaa
</div>
<div class="blue">
bbbbbbbbbbbbb
</div>
</div>
<div class="clearBoth">
<div class="yellow">
aaa
</div>
<div class="green">
bbbbbbbbbbbbb
</div>
</div>
</div>
</div>
</body>
</html>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉祥县| 靖西县| 贵德县| 静宁县| 迭部县| 凤台县| 什邡市| 绥江县| 竹北市| 边坝县| 辽阳市| 鸡东县| 康乐县| 峨眉山市| 十堰市| 松原市| 盐津县| 故城县| 赤城县| 彭州市| 顺平县| 溆浦县| 英超| 土默特左旗| 湘潭市| 改则县| 雷州市| 长葛市| 黑水县| 井陉县| 卓资县| 汉沽区| 贡山| 澄迈县| 仙游县| 犍为县| 汉源县| 盐津县| 镇远县| 仙桃市| 贺州市|