设置html宽、高、颜色及文本、文字水平居中

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>笔记</title>
    <style>
        body{
            margin: 0;
        }
        .head_area{
            width: 100%;                /*设置宽度*/
            height: 40px;               /*设置高度*/
            color: beige;               /*设置字体颜色*/
            background-color:black;    /*设置背景颜色*/
            text-align: center;         /*让文本水平居中*/
            line-height: 40px;          /*让文本垂直居中*/
        }
        .body_area{
            width: 100%;
            height: 100px;
            background-color: blue;
            text-align: center;
            line-height: 100px;    /*让文本水平居中就是让他的行高等于文本本身的高度*/
        }
        .tail_area{
            width: 100%;
            height: 100px;
            background-color:chocolate;
            text-align: center;
            line-height: 100px;
        }

    </style>
</head>
<body>
<div class="head_area">黑色区域</div>
<div class="body_area">内容区域</div>
<div class="tail_area">尾部区域</div>
</body>
</html>

 

posted @ 2019-08-13 19:39  杨灏  阅读(1636)  评论(0)    收藏  举报