定位法

<!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;
            position: relative;
        }
        .left{
            width: 200px;
            height: 300px;
            background-color: pink;
            position: absolute;
            top: 0;
            left:0;
            position: absolute;
        }
        .right{
            width: 150px;
            height: 300px;
            background-color: purple;
            position: absolute;
            top: 0;
            right: 0;
        }
        .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>

 



与浮动法原理一样
posted @ 2019-08-18 16:16  菜鸟小何  阅读(252)  评论(0编辑  收藏  举报