在3-5的練習中,我是否可以對footer部分添加<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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
* {
? ? margin:0;
padding:0;
}
#wrap {
background:#00C;
margin:0 auto;
width:960px;
}
#header {
background:#FF3300;
width:100%;
}
#mainbody {
? ?background:#FC0;
}
.left {
width:800px;
height:200px;
background:#000;
float: left;
}
.right {
width:140px;
height:500px;
background:#690;
float: right;
}
#footer {
background:#639;
width:100%;
clear: both;
}
</style>
</head>
<body>
<div id="wrap">
? <div id="header">頭部</div>
? <div id="mainbody">
? ? <div class="left"></div>
? ? <div class="right"></div>
? </div>
? <div id="footer">版權部分</div>
</div>
</body>
</html>
2016-02-15
在footer用clear ?那個mainbody的顏色顯示的是#wrap里的#00C顏色,跟效果圖不一樣的
2015-12-26
可以是可以,效果不會有什么差異。前提你要清楚你為什么要清楚浮動,你的footer又沒有浮動,何必多此一舉呢?你問背景色變藍的原理是想問瀏覽器工作原理么