HTML&CSS基础-背景的简写属性
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.HTML源代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>背景的简写属性</title> </head> <style type="text/css"> body{ height: 5000px; /*设置一个颜色*/ /*background-color: deeppink;*/ /*设置一个图片背景*/ /*background-image: url(img/02.png);*/ /*设置背景图片不重复*/ /*background-repeat: no-repeat;*/ /*设置图片背景位置*/ /*background-position: center center;*/ /*设置背景图片不随滚动条滚动*/ background-attachment: fixed; /** * background: * 通过该属性可以同时设置所有背景相关的样式,没有顺序的要求,谁在前谁在后都行; * 该属性也没有数量的要求,不写的样式就使用默认值。 */ background: yellow url(img/02.png) no-repeat center center fixed ; } </style> <body> </body> </html>
二.浏览器打开以上代码渲染结果