让div充满整个body

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin:0px;
            padding:0px;
        }

        .test{
            background-color: pink;
            height: 100%;
            width:100%;
            position:absolute;
        }
    </style>
</head>
<body>
    <div class="test">
        fdsaf
    </div>
</body>
</html>

position如果不设置,body里的div height百分比设置不起作用,具体数值才起作用

posted @ 2019-03-14 16:00  手指乐  阅读(918)  评论(0编辑  收藏  举报