background-attachment 定义和用法
background-attachment 属性设置背景图像是否固定或者随着页面的其余部分滚动。
可能的值
实现背景图片固定的实用代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>背景固定大法</title>
<!--<link rel="stylesheet" href="css/main.css" />-->
<style>
body{
background-image: url(http://pic1.win4000.com/wallpaper/2017-10-14/59e1bb9f01314.jpg);
background-repeat: no-repeat; /*照片不重复*/
background-attachment: fixed;
}
</style>
</head>
<body>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
<p>传说中的背景固定大法</p>
</body>
</html>
如果您觉得本文的内容对您的学习有所帮助:
关键字:
css