使用CSS设置背景附件
若要设置背景附件,请使用background-attachment属性。背景附件确定背景图像是固定的还是随页面的其余部分滚动。
示例
您可以尝试运行以下代码,以了解如何使用background-attachment属性设置固定的背景图片:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>热门推荐
10 佛教生日祝福语简短大全
11 过节文案成语祝福语简短
12 学生开学季祝福语简短
13 新婚迎宾海报祝福语简短
14 形容新年的祝福语简短
15 祝福语大全简短赞美同学
16 妹妹生日祝福语简短唯美
17 整形机构开业祝福语简短
18 小红书平安祝福语简短