HTML基本布局

2025-10-26 20:55:31

1、新建一个HTML文档,如图所示

HTML基本布局

HTML基本布局

2、定义页眉,页脚,侧边栏和内容,在body标签里输入

<div class="">

    <div id="">页眉</div>

    <div class="">侧边栏</div>

    <div class="">主内容</div>

    <div id="">页脚</div>

</div>

如图所示

HTML基本布局

3、然后定义他们的id和class,如图所示

HTML基本布局

4、然后在head标签里定义css文件,如图所示

HTML基本布局

5、编写全体输入

* {

    margin: 0;

    padding: 0;

}

如图所示

HTML基本布局

6、编辑定位整体,输入

.wrapper {

    width: 960px;

    margin-left: auto;

    margin-right: auto;

    color: #fff;

    font-size: 30px;

    text-align: center;

}

如图所示

HTML基本布局

7、编写页眉,输入

#header {

    height: 100px;

    background: #38382e;

    margin-bottom: 10px;

}

HTML基本布局

8、编写页脚。输入

#footer {

    background: #cc4ad5;

    height: 100px;

    text-align: center;

    clear: both;

}

HTML基本布局

9、编写侧边栏,输入

.sidebar {

    float: left;

    width: 220px;

    margin-right: 20px;

    margin-bottom: 10px;

    height: 300px;

    background: #5d33cf;

}

HTML基本布局

10、编写内容部分,输入

.content {

    float: left;

    width: 720px;

    height: 300px;

    background: #c8ca30;

    margin-bottom: 10px;

}

HTML基本布局

11、最后按f12预览即可

HTML基本布局

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢