HTML常用布局方式

  • 作者简介:一名后端开发人员,每天分享后端开发以及人工智能相关技术,行业前沿信息,面试宝典。
  • 座右铭:未来是不可确定的,慢慢来是最快的。
  • 个人主页极客李华-CSDN博客
  • 合作方式:私聊+
  • 这个专栏内容:BAT等大厂常见后端java开发面试题详细讲解,更新数目100道常见大厂java后端开发面试题。
  • 我的CSDN社区:https://bbs.csdn.net/forums/99eb3042821a4432868bb5bfc4d513a8
  • 微信公众号,抖音,b站等平台统一叫做:极客李华,加入微信公众号领取各种编程资料,加入抖音,b站学习面试技巧,职业规划

前言:对HTML的学习,在了解了基础的语法之后,需要学习与掌握的是,HTML的基础布局方式,这个是网页布局的基础,本文讲解是当前常用布局。

布局一

示例图

在这里插入图片描述

代码部分

<!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>
        .header{
            border-style: solid;  /*设置边框样式*/
            text-align: center; /*让文字居中*/
            height: 100px;
            width: 100%; /*设置宽度为浏览器100%*/
        }
        .left{
            height: 500px;
            width: 20%;
            margin-top: 10px;
            display: inline-block; /*设置块类元素为行内块*/
            border-style: solid;
            text-align: center;
        }
        .center{
            height: 500px;
            width: 79%;
            margin-top: 10px;
            display: inline-block;
            border-style: solid;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="header">header</div>
    <div class="left">left</div>
    <div class="center">center</div>
</body>
</html>

布局二

在这里插入图片描述
代码部分

<!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>
        .header{
            border-style: solid;  /*设置边框样式*/
            text-align: center; /*让文字居中*/
            height: 100px;
            width: 100%;
        }   
    
        .center{
            height: 500px;
            width: 100%;
            margin-top: 10px;
            display: inline-block;
            border-style: solid;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="header">header</div>
    <div class="center">center</div>
</body>
</html>

布局三

在这里插入图片描述
代码部分

<!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>
        .center{
            height: 500px;
            width: 100%;
            border-style: solid;
            text-align: center;
            margin-bottom: 10px;
        }
        .buttom{
            height: 200px;
            width: 100%;
            border-style: solid;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="center">center</div>
    <div class="buttom">buttom</div>
</body>
</html>

布局四

在这里插入图片描述
代码部分

<!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>
        .border1{
            border-style: solid;
            text-align: center;
        }
        .header{
            height: 200px;
            width: 100%;
        }
        .left{
            width: 23.5%;
            display: inline-block;
        }
        .center{
            width: 50%;
            display: inline-block;
        }
        .right{
            width: 23.5%;
            display: inline-block;
        }
        .buttom1{
            margin-top: 10px;
            margin-bottom: 10px;
            height: 200px;
        }
        .buttom{
            height: 200px;
            width: 100%;
        }
    </style>
</head>
<body>
    <div class="header border1" >header</div>
    <div class="left border1 buttom1">left</div>
    <div class="center border1 buttom1">center</div>
    <div class="right border1 buttom1">right</div>
    <div class="buttom border1">buttom</div>
</body>
</html>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

极客李华

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

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

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

打赏作者

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

抵扣说明:

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

余额充值