<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>雙外邊距bug</title> <style type="text/css"> * { margin: 0; padding: 0; } .box1{ background: red; width: 100px; height: 50px; float: left; margin-left: 20px; margin-top: 20px; /*設置display修復雙外邊距bug*/ /*display: inline;*/ } .box2{ background: blue; width: 100px; height: 50px; float: left; margin-left: 20px; margin-top: 20px; } </style></head><body> <div class="box1"> </div> <div class="box2"> </div></body></html>
.myFloat { float:left; width:200px; margin-left 200px; }p{ margin-left: 200px;}
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>3像素文本偏移bug</title> <style type="text/css"> * { margin: 0; padding: 0; } .myFloat { float:left; background: red; width:200px; height: 100px; } p{ margin-left: 200px; width: 200px; background: orange; } </style></head><body> <div class="myFloat"> </div> <p class="first">今天跟你們分享一個免費下載資源的網站——<a href="http://www.1001freedownloads.com/">1001FreeDownloads</a>它擁有超過1000個免費的設計圖像和字體的目錄。這個獨特的網站提供了多種能夠用來做爲剪貼簿頁面,圖標和壁紙。 </body> </html>
- 相信你能夠在這裏找到你想要的素材。前端er、設計師們收藏咯!</p>
<!-- [if lt IE 7] --> 針對IE7如下的樣式<!-- [endif] -->
p{ height:1%;}
p{ margin-left:0; height:1%;}
p{ margin-left:0; height:1%;}.myFloat{ margin-right:-3px;}
<html><head> <meta charset="utf-8"> <title>3像素文本偏移bug</title> <style type="text/css"> * { margin: 0; padding: 0; } #left { float: left; width: 200px; height:100px; background:red; } #right { width: 200px; height:100px; background:blue; margin-left: 200px; } /*刪除#right的margin-left*,並添加下面的樣式修復bug/ /*#left { margin-right:-3px; } */ </style></head><body> <div id="left"></div> <div id="right"></div> </body></html>
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title> <style type="text/css"> *{ margin: 0;padding: 0; } .box{ position:relative; border:2px solid red; } .box1{ width: 300px; height: 200px; } .box2{ width: 50px; height: 50px; position:absolute; bottom:0; left:0; background:#CCC; } </style></head><body> <div class="box"> <div class="box1"></div> <div class="box2">絕對浮動框</div> </div></body></html>