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中文网其它相关文章!
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号