实现常见的网页布局

🌟 所属专栏:前端只因变凤凰之路
🐔 作者简介:rchjr——五带信管菜只因一枚
😮 前言:该系列将持续更新前端的相关学习笔记,欢迎和我一样的小白订阅,一起学习共同进步~
👉 文章简介:本文介绍网页的常见布局。知识学习内容来自b站的 @黑马程序员 的视频

本篇文章实现上面常见的网页布局,其中一共分为4个部分,下面为数据

top

height:50px width:100%(或者不写,默认是和浏览器一样宽)

banner

height:150px width:980px margin:10px auto

box

height:300px width:980px margin:0 auto

box li

height:300px width:237px float:left margin-right:10px (最后一个为0)

footer

height:200px margin-top:10px width:100%(或者不写,默认是和浏览器一样宽)

<!DOCTYPE html>
<html lang="en">

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

        .top {
            height: 50px;
            background: #ccc;
        }

        .banner {
            height: 150px;
            width: 980px;
            margin: 10px auto;
            background-color: #ccc;
        }

        .box {
            height: 300px;
            width: 980px;
            margin: 0 auto;
            background-color: #ccc;
        }

        li {
            list-style: none;
        }

        .box li {
            height: 300px;
            width: 237px;
            float: left;
            background-color: aqua;
            margin-right: 10px;
        }

        .box .last {
            margin-right: 0;
        }

        .footer {
            height: 200px;
            margin-top: 32px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <div class="top">top</div>
    <div class="banner">banner</div>
    <ul class="box">
        <ul>
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li class="last">4</li>
        </ul>
    </ul>
    <div class="footer">footer</div>
</body>

</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

诺坎普的风间

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值