使用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 同学道别祝福语简短