<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>"float: left" element </title>
<style type="text/css" media="screen">
body {
margin: 20px;
padding: 0;
font: normal 85% arial, helvetica, sans-serif;
color: #000;
background-color: #fff;
}
.containingbox {
width: 400px;
height: 400px;
border: 1px solid #000;
}
.floatleft {
float: left;
width: 100px;
height: 100px;
border: 2px solid #F63;
}
p.highlight { border: 5px solid #aaa; }
</style>
</head>
<body>
<div class="containingbox">
<div class="floatleft"></div>
<p class="highlight">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
</div>
</body>
</html>
爲什麼此塊內容與邊框:<p class="highlight">Lorem ipsum...</p>
在同一水平<div class="floatleft"></div>
沒有顯示?當我用螢火蟲檢查它(<p class="highlight">Lorem ipsum...</p>
)時,似乎有margin-top
和margin-bottom
爲它設置,但在css中沒有margin
代碼。所以爲什麼?
把你的代碼中的jsfiddle。這將更容易調試 – Exception