利用自身的浮动布局

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .container{
            width: 100%;
            background-color: green;
            min-height: 500px;
        }
        .left{
            width: 200px;
            height: 300px;
            background-color: pink;
            float: left;
        }
        .right{
            width: 150px;
            height: 300px;
            background-color: purple;
            float: right;
        }
        .center{
            height: 300px;
            margin-left: 200px;
            margin-right: 150px;
            background-color: blue;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
        5236
    </div>
</div>
</body>
</html>

这个方法容易理解,但是记住不要给center设置宽度

 

posted @ 2019-08-18 16:10  菜鸟小何  阅读(125)  评论(0编辑  收藏  举报