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; 成了,开心。