css2

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; }

 

posted @ 2016-05-14 14:26  gyz418  阅读(133)  评论(0)    收藏  举报