H5/Web前端开发教程

10. CSS 排版

2017-04-10  本文已影响4人  一Left一

1、标准流(文档流/普通流)

2、浮动排版 float属性

3、浮动元素脱标

 .box1{
            width: 100px;
            height: 100px;
            background-color: red;
            float: left;
        }
        .box2{
            width: 150px;
            height: 150px;
            background-color: burlywood;
        }

4、隔墙法

<head>
    <meta charset="UTF-8">
    <title>隔墙法-外墙法</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box1{
            background-color: antiquewhite;
        }
        .box2{
            background-color: darkgrey;
        }
        .box1 p{
            width: 100px;
            background-color: blue;
        }
        .box2 p{
            width: 100px;
            background-color: magenta;
        }
        p{
            float: left;
        }
        .wall{
            clear: both;
            height: 20px;
            background-color: aquamarine;
        }
    </style>
</head>
<body>
    <div class="box1">
        <p>我是文字1</p>
        <p>我是文字2</p>
        <p>我是文字3</p>
    </div>
    <div class="wall"></div>
    <div class="box2">
        <p>我是文字4</p>
        <p>我是文字5</p>
        <p>我是文字6</p>
    </div>
</body>
<body>
    <div class="box1">
        <p>我是文字1</p>
        <p>我是文字2</p>
        <p>我是文字3</p>
        <div class="wall"></div>
    </div>
    <div class="box2">
        <p>我是文字4</p>
        <p>我是文字5</p>
        <p>我是文字6</p>
    </div>
</body>

5、overflow:hidden

上一篇 下一篇

猜你喜欢

热点阅读