码迷,mamicode.com
首页 > 其他好文 > 详细

H5 66-清除浮动方式二

时间:2017-04-02 17:49:37      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:规则   ima   title   ack   排序   lang   方式   清除浮动   char   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>66-清除浮动方式二</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            border: 1px solid #000;
        }
        .box1{
            background-color: red;
        }
        .box2{
            background-color: green;
            clear: both;
            margin-top: 28px;
        }
        .box1 p{
            width: 100px;
            background-color: blue;
        }
        .box2 p{
            width: 100px;
            background-color: yellow;
        }
        p{
            float: left;
        }
        /*
        .dd{
            width: 500px;
            height: 500px;
            background-color: red;
            border: 1px solid #000;
        }
        .ddd{
            width: 200px;
            height: 200px;
            background-color: blue;
            margin-top: 100px;
        }
        */
    </style>
</head>
<body>
<!--
1.清除浮动的第二种方式
给后面的盒子添加clear属性

clear属性取值:
none: 默认取值, 按照浮动元素的排序规则来排序(左浮动找左浮动, 右浮动找右浮动)
left: 不要找前面的左浮动元素
right: 不要找前面的右浮动元素
both: 不要找前面的左浮动元素和右浮动元素

注意点:
当我们给某个元素添加clear属性之后, 那么这个属性的margin属性就会失效
-->

<div class="box1">
    <p>我是文字1</p>
    <p>我是文字1</p>
    <p>我是文字1</p>
</div>

<div class="box2">
    <p>我是文字2</p>
    <p>我是文字2</p>
    <p>我是文字2</p>
</div>

<!--
<div class="dd">
    <div class="ddd"></div>
</div>
-->
</body>
</html>

技术分享

H5 66-清除浮动方式二

标签:规则   ima   title   ack   排序   lang   方式   清除浮动   char   

原文地址:http://www.cnblogs.com/ljcgood66/p/6659296.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!