CSS+DIV之强化background属性
2016-01-13 13:52
543 查看
1.背景颜色属性(background-color),设定背景颜色=html中bgcolor属性。我来写一个红色背景的body,(也可以定义某个特定区域)
示例写法:body {}
2.背景图片属性(background-image),设定背景图片=html中background属性,为body设置一个背景图片。
示例写法:body {background-image:url(../images/图片路径)”}
3.背景重复属性(background-repeat),它和背景图片属性连用,决定背景图片是否重复。在默认不设置状态下,图片向横向、坚向重复。其相关参数主要有:repeat-x 背景图片横向重复,repeat-y背景图片竖向重复,no-repeat背景图片不重复。
示例写法:body {background-image:url(../images/图片路径);background-repeat:repeat-y;}
4.背景附着属性(background-attachment),类似于背景重复属性,和背景图片属性连用,决定图片是否跟随内容滚动。其参数值主要有:scroll(滚动),fixed(固定),默认为scroll。
示例写法:body {background-image:url(../images/图片路径); background-repeat:no-repeat; background-attachment:fixed;}
5.背景位置属性(background-position),类似于背景重复属性,和背景图片属性连用,
决定背景图片的最初位置。下面写入一个背景图片的初始位置距离网页最左面5px,距离网页最上面10px。
示例写法:body {background-image:url(../images/图片路径);background-repeat:no-repeat; background-position:5px 10px;}
6.背景属性(background),背景相关属性的综合写法,包括上述写的五个属性。这个简洁的写法可以省略background-color, background-image, background-repeat,backgroundattachment, background-position。
示例写法:body {background:#000 url(../images/图片路径) no-repeat fixed 5px 10px;}
示例写法:body {}
2.背景图片属性(background-image),设定背景图片=html中background属性,为body设置一个背景图片。
示例写法:body {background-image:url(../images/图片路径)”}
3.背景重复属性(background-repeat),它和背景图片属性连用,决定背景图片是否重复。在默认不设置状态下,图片向横向、坚向重复。其相关参数主要有:repeat-x 背景图片横向重复,repeat-y背景图片竖向重复,no-repeat背景图片不重复。
示例写法:body {background-image:url(../images/图片路径);background-repeat:repeat-y;}
4.背景附着属性(background-attachment),类似于背景重复属性,和背景图片属性连用,决定图片是否跟随内容滚动。其参数值主要有:scroll(滚动),fixed(固定),默认为scroll。
示例写法:body {background-image:url(../images/图片路径); background-repeat:no-repeat; background-attachment:fixed;}
5.背景位置属性(background-position),类似于背景重复属性,和背景图片属性连用,
决定背景图片的最初位置。下面写入一个背景图片的初始位置距离网页最左面5px,距离网页最上面10px。
示例写法:body {background-image:url(../images/图片路径);background-repeat:no-repeat; background-position:5px 10px;}
6.背景属性(background),背景相关属性的综合写法,包括上述写的五个属性。这个简洁的写法可以省略background-color, background-image, background-repeat,backgroundattachment, background-position。
示例写法:body {background:#000 url(../images/图片路径) no-repeat fixed 5px 10px;}
相关文章推荐
- CSS中强大的EM
- CSS值得关注的那些事?
- CSS值得关注的那些事?
- css3 中的filter使用
- wpf 样式继承
- Css
- 【HTML打卡】0113 div布局,css控制
- CSS 垂直居中问题总结
- 纯CSS3实现自定义涂鸦风格的边框
- css3 实现圆角边框的border-radius属性和实现阴影效果的box-shadow属性
- CSS 样式修改 积累
- TabHost(系统自带样式)
- 从$('li').filter(':even').css('background-color', 'red');说起
- chrome查看hover样式方法
- animate.css css3动画工具
- 五,JavaWeb简略的谈下前端技术<二>CSS层叠样式表
- CSS 简介
- CSS 语法
- CSS Id 和 Class
- CSS 创建