body css样式中 设置宽度和背景色
2016-06-22 20:12
411 查看
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> body{ padding:0; margin:0; margin:0 auto; background-color:#069; width:80%; height:800px; border:1px solid #F00; } div{ height:200px; width:200px; border:1px solid #0F0; } </style> </head> <body> <div class="wrap"> </div> </body> </html>
如上面
之前一般都是用div元素包含整个页面的内容,然后设置宽度,如width:80% 或者 width:620px margin:0 auto; 从而实现将主体元素居中显示、
也可以在CSS样式中设置body样式,如上面。
这样元素主体内容就是居中显示,但是背景色是渲染整个页面的,说明背景色是整个页面起作用。
这种形式一般很少用,可以用来设置页面的基础样式,如字体,打开方式,背景等。
相关文章推荐
- body css样式中 设置宽度和背景色
- body css样式中 设置宽度和背景色
- [DIV/CSS] CSS-清除浮动
- 使用CSS选择器定位页面元素
- [DIV/CSS] (CSS) 不同浏览器对table中visibility属性显示的不同
- CSS选择器
- 使用font-awesome图标,css元素选择器(i)下,部分设置不生效的问题之解决。
- css3loading状态3
- css3loading 状态4
- DIV六种实现元素水平居中
- CSS中的绝对定位与相对定位
- css设置placeholder
- ASM disk header 备份与恢复、单机ASM下CSS进程无法启动
- 第二章 CSS工作原理(伪类与伪元素)
- github 各种控件样式(动画效果)
- 第二章 CSS工作原理(ID属性和类选择符)
- CSS3 2D转换
- css3 div 居中
- CSS基础及选择器
- CSS3 选择器