如何在css中设置版心宽?

html-css012

如何在css中设置版心宽?,第1张

布局流程为了提高网页制作的效率,布局时通常需要遵守一定的布局流程,具体如下:1、确定页面的版心(可视区)。2、分析页面中的行模块,以及每个行模块中的列模块。3、制作HTML结构 。4、CSS初始化,然后开始运用盒子模型的原理,通过DIV+CSS布局来控制网页的各个模块。 一列固定宽度且居中案例<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style>.box {width: 900pxbackground-color: #eeeborder: 1px dashed #cccmargin: 0 auto}.top {height: 80px}.banner {height: 120px/*margin: 0 auto*/margin: 5px auto}.main {height: 500px}.footer {height: 100px/*margin: 0 automargin-top:5px*/ margin: 5px auto 0}</style></head><body><div class="top box">top</div><div class="banner box">banner</div><div class="main box"></div><div class="footer box"></div></body></html>

1、首先打开hbuilder软件,新建一个html文件,写入一个p标签,里面写入一句话:

2、然后在上方定义style标签,修改body标签的样式,这里用width属性设置body的宽度为600像素,高度设为1000,居中使用margin属性,最后为了观察效果最后在设置一个宽度为10像素的边框并给边框一个颜色:

3、最后按下Crtl+S保存,在浏览器中就可以看到自定义宽度并居中的body标签了: