手册
目录
为了缩短代码,也可以在一个属性中指定所有的背景属性。这被称为简写属性。
不必这样写:
body {<br></br> background-color: #ffffff;<br></br> background-image:
url("img_tree.png");<br></br> background-repeat: no-repeat;<br></br>
background-position: right top;<br></br>}
运行实例 »点击 "运行实例" 按钮查看在线实例
你可以使用简写属性 background:
使用简写属性在一个声明中设置背景属性:
body {<br></br> background: #ffffff url("img_tree.png") no-repeat right top;<br></br>}
运行实例 »点击 "运行实例" 按钮查看在线实例
使用简写属性时,属性值的顺序为:
background-colorbackground-imagebackground-repeatbackground-attachmentbackground-position只要属性值顺序正确,缺少其中某一个属性值也没有关系。请注意上面的例子中没有使用 background-attachment 属性,因为它没有设置值。
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.3万人学习
共49课时
77.7万人学习
共29课时
62.2万人学习
共25课时
39.6万人学习
共43课时
71.5万人学习
共25课时
62.1万人学习
共22课时
23.2万人学习
共28课时
34.2万人学习
共89课时
126.3万人学习