HTML 中设置网页背景有6种方法:① 背景色;② 背景图像;③ 背景重复;④ 背景位置;⑤ 背景大小;⑥ 背景附件。
HTML 中设置网页背景
HTML 中可以通过以下方法设置网页背景:
1. 背景色(background-color)
使用 background-color
属性设置均匀背景色。
语法:
<body style="background-color: #cccccc;">
2. 背景图像(background-image)
使用 background-image
属性设置背景图像。
语法:
<body style="background-image: url('background.jpg');">
3. 背景重复(background-repeat)
使用 background-repeat
属性控制背景图像的重复方式。
语法:
<body style="background-image: url('background.jpg'); background-repeat: repeat;">
4. 背景位置(background-position)
使用 background-position
属性控制背景图像的位置。
语法:
<body style="background-image: url('background.jpg'); background-position: left top;">
5. 背景大小(background-size)
使用 background-size
属性控制背景图像的大小。
语法:
<body style="background-image: url('background.jpg'); background-size: 100% 100%;">
6. 背景附件(background-attachment)
使用 background-attachment
属性控制背景图像是否随页面滚动而滚动。
语法:
<body style="background-image: url('background.jpg'); background-attachment: fixed;">
以上是html怎么做网页背景的详细内容。更多信息请关注PHP中文网其他相关文章!