您现在的位置是:首页 > 编程 > 

HTML常用布局方式

2025-07-23 03:16:42
HTML常用布局方式 前言:对HTML的学习,在了解了基础的语法之后,需要学习与掌握的是,HTML的基础布局方式,这个是网页布局的基础,本文讲解是当前常用布局。布局一示例图:代码部分:代码语言:javascript代码运行次数:0运行复制<!DOCTYPE html> <html lang="en"> <head> <meta

HTML常用布局方式

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

布局一

示例图

代码部分

代码语言:javascript代码运行次数:0运行复制
<!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>
布局二

代码部分

代码语言:javascript代码运行次数:0运行复制
<!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>
布局三

代码部分

代码语言:javascript代码运行次数:0运行复制
<!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>
布局四

代码部分

代码语言:javascript代码运行次数:0运行复制
<!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: 2.5%;
            display: inline-block;
        }
        .center{
            width: 50%;
            display: inline-block;
        }
        .right{
            width: 2.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>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2024-02-01,如有侵权请联系 cloudcommunity@tencent 删除基础htmlcenterwidth布局

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/biancheng/1155209.html

相关标签:无
上传时间: 2025-07-20 05:35:48
留言与评论(共有 15 条评论)
本站网友 植物染发加盟店
5分钟前 发表
100%; } .left{ width
本站网友 温州职业技术学院地址
30分钟前 发表
79%; margin-top
本站网友 拔罐减肥法
16分钟前 发表
100%; } .left{ width
本站网友 增强记忆力的音乐
13分钟前 发表
50%; display
本站网友 广东电影院
18分钟前 发表
100%; border-style
本站网友 宁波东海花园
23分钟前 发表
10px; display
本站网友 韵达物流
22分钟前 发表
center; /*让文字居中*/ height
本站网友 天天泡
19分钟前 发表
center; margin-bottom
本站网友 治疗焦虑症
5分钟前 发表
10px; height
本站网友 hcse
2分钟前 发表
500px; width
本站网友 斗战神黑屏
12分钟前 发表
center; margin-bottom
本站网友 太原租房子
5分钟前 发表
100px; width
本站网友 艾条的作用
30分钟前 发表
200px; width
本站网友 何阳
4分钟前 发表
在了解了基础的语法之后