HTML 页面滚动时背景图片不会移动

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
	/*兼容IE6+,火狐,谷歌,欧朋,苹果*/
	background: url(bg.jpg) no-repeat center top fixed;
	/*background-attachment: fixed;*/
	/*background-attachment :定义背景图片随滚动轴的移动方式
	取值: scroll | fixed | inherit
	scroll: 默认值。背景图像会随着页面其余部分的滚动而移动。
	fixed: 当页面的其余部分滚动时,背景图像不会移动。
	inherit: 继承初始值: scroll(任何版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。)
	继承性: 否
	适用于: 所有元素*/
}
</style>
</head>
<body>
<div style="height: 10000px;"></div>
</body>
</html>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2323283