css2

时间:2022-06-08 22:28:21
CSS 实现div宽度根据内容自适应
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>脚本之家</title>
<style type="text/css">
.parent{
width:400px;
height:400px;
border:1px solid red;
}
.children{
border:1px solid blue;
height:50px;
display:inline-block; /*这三行*/
*display:inline; /* css hack 兼容ie6 */
*zoom:1;
}
</style>
</head>
<body>
<div class="parent">
<div class="children">CSS 实现div宽度根据内容自适应</div>
</div>
</body>
</html>

clear写法?

.clear { zoom:1; }
.clear:after { content:''; display:block; clear:both; }