background-position属性生效,背景却没有移动

css样式中有个background-position背景属性,是关于对背景在对象中的精准定位。
1. background-position: 水平方位 垂直方位(right left top bottom center)
2. background-position-x: 水平方向移动
3. background-position-y:垂直方向移动
4. 结合一起来,一个容器里正方向上就有9个方位可选择。
重点来了,是背景在容器中的方位变化,当你的背景和你的容器一般大的时候,你的定位根本就不会变,这次我就出现了这样的问题。

<style type="text/css">
			#banner{
				background-image:url(file.jpg);
				background-repeat: no-repeat;
				background-position:right bottom;
			}
		</style>
	</head>
	<body>
		<div id="banner"></div>
	</body>

我的容器和我的背景一般大,背景图始终停留在左上角,没有变化。
我将我的容器设置了大小,height:800px;width:800px; 成了,开心。
在这里插入图片描述

发布了13 篇原创文章 · 获赞 7 · 访问量 4551

猜你喜欢

转载自blog.csdn.net/Bcxbclj/article/details/102723520