详解:41 background-attachment

2020-10-28 15:25:37 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css"/>
	<style type="text/css">
		div{
			height: 150px;
			border:1px solid gray;
			background-image:url(images/king1.jpg);
			margin:50px;
			overflow-x:hidden;
			overflow-y:scroll;
			background-repeat: no-repeat;
		}
		.scroll{
			background-attachment: scroll;/*主视图:浏览器页的滚动条,本地视图:页面内的滚动条,以背景为例,他会和主视图一起滚动,本地视图不动*/
		}
		.fixed{
			background-attachment: fixed;/*因为是相对于窗口进行固定的哈,背景只在页面的某一个位置,固定的位置哈*/
		}
		.local{
			background-attachment: local;/*主视图本地视图都会动*/
		}
	</style>
</head>
<body>
<div class="scroll">
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
	background-attachment:scroll,default,默认值<br/>
</div>
<div class="fixed">
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
	background-attachment:fixed,相对于窗口固定<br/>
</div>
<div class="local">
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
	background-attachment:local,相对元素内容<br/>
</div>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>
<p>this is a test</p>

</body>
</html>

0 人点赞