DIV-CSS布局

DIV-CSS布局

DIV-CSS布局

在这里插入图片描述

<!DOCTYPE html>
<html>

<head>
    <title>Document</title>
    <style type="text/css">
        * {
            /* 外边距4个方向全为0 */
            margin: 0px;
            /* 内边距4个方向全为0*/
            padding: 0px;
        }
        
        a {
            /* 链接默认没有下划线*/
            text-decoration: none;
        }
        
        ul {
            /* 列表默认没有项目符合*/
            list-style: none;
        }
        
        header,
        section,
        footer {
            /* 头 中 尾 默认CSS样式*/
            /* 宽度1000px*/
            width: 1000px;
            /* 居中*/
            margin: 0 auto;
            /* 背景色 粉红色*/
            background-color: pink;
        }
        
        header,
        footer {
            /* 头 尾 给一个80px高度*/
            height: 80px;
        }
        
        section {
            /* 中 上下给20px页边距 矩阵 */
            margin: 20px auto;
            /* 清除浮动,露出底部区域*/
            overflow: hidden;
        }
        
        section>div {
            /* 因为section中左、右两个div是横向排列,所以给一个左浮动*/
            float: left;
            /* 给一个浅灰色背景色*/
            background-color: #ccc;
            /* 预先给一个高度,一会儿还要删掉*/
            /* height: 300px; */
        }
        
        .left {
            /* 中 左边div给700px,因为它稍宽一些*/
            width: 680px;
            /* 给右侧一个边距*/
            margin-right: 20px;
        }
        
        .left>div {
            /* 给left下边的每个div设置200px高度*/
            height: 200px;
            /* 给left下边的每个div设置下边距20px*/
            /* margin-bottom: 20px; */
            /* 背景色*/
            background-color: yellow;
        }
        
        .left>div:nth-child(-n+2) {
            /* 只对.left_one和.left_two进行CSS定义方式2*/
            margin-bottom: 20px;
        }
        
        .left_one>div {
            background-color: yellowgreen;
            height: 100%;
            float: left;
        }
        
        .left_one_1 {
            width: 180px;
        }
        
        .left_one_2 {
            width: 480px;
            margin-left: 20px;
        }
        
        .right {
            /* 中 右边div给300px,因为它稍为窄一些 */
            width: 300px;
        }
        
        .right>div {
            /* 给right下边的每个div设置200px高度 */
            height: 200px;
            background-color: yellow;
        }
        
        .right>div:nth-child(-n+3) {
            /*只对.right下的前3个div设置下边距*/
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <header>
        头部区域
    </header>
    <section>
        <div class="left">
            <div class="left_one">
                <div class="left_one_1"></div>
                <div class="left_one_2"></div>
            </div>
            <div class="left_two"></div>
            <div class="left_three"></div>
        </div>
        <div class="right">
            <div class="right_one"></div>
            <div class="right_two"></div>
            <div class="right_three"></div>
            <div class="right_four"></div>
        </div>
    </section>
    <footer>
        底部区域
    </footer>
</body>

</html>

参考:

https://www.bilibili.com/video/BV11741177cJ?spm_id_from=333.880.my_history.page.click

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值