1. 程式人生 > >網頁中常見的排版 (關鍵點:浮動)

網頁中常見的排版 (關鍵點:浮動)

 

排版格式如上。

考點:浮動,具體用法可參考http://www.w3school.com.cn/css/css_positioning_floating.asp

<!DOCTYPE html>

<html>
<head>
<meta http-equiv="" content="" >
<meta name="" content="">
<!-- 真是懵逼了,meta標籤沒有結束標籤 -->
<style>
*{
margin:0;
padding:0;
border:0;
}
.leftBox{
width:30px;
height:30px;
border:1px black solid;
float:left;
}
.rightBox{
width:300px;
height:100px;
border-bottom:1px black solid;
margin-bottom:10px;
margin-left:10px;
float:left;
}
.clear{
clear:both;
}
img{
width:50px;
height:50px;
margin-right:5px;
border:1px black solid;
float:left;
}

</style>
</head>
<body>
<div>
<div class="leftBox"></div>
<div class="rightBox">
<p>QQQQQQQQQQQQQQ</p>
<div >
<img src=""/>
<p>OOOOOOOOOOOO</p>
</div>
<p class="clear" >JJJJJJJJJJJJ</p>
</div>
<div class="clear"></div>
</div>

<div>
<div class="leftBox"></div>
<div class="rightBox">
<p>DDDDDDDDDDDDDDDD</p>
<div>
<img src=""/>
<p>WWWWWWWWWWWWWWW</p>
</div>
<p class="clear" >JJJJJJJJJJJJ</p>
</div>
<div class="clear"></div>
</div>
     </body>
</html>