我正在尝试使用CSS的background-image和position属性在主页中放置一张图片,以更改其偏移量。
问题是,当我调整浏览器的大小时,图片将保持静态且不会相应地移动。
有什么方法可以实现这一点吗?
谢谢。
问题是,当我调整浏览器的大小时,图片将保持静态且不会相应地移动。
有什么方法可以实现这一点吗?
谢谢。
使用百分比:background-position: 50% 50%
将使背景图片居中显示。
background: url(../images/bodyBG2.gif) center center no-repeat;
或者
background: url(../images/bodyBG2.gif) 50% 50% no-repeat;
或者
background-image: url(../images/bodyBG2.gif);
background-repeat: no-repeat;
background-position: 50% 50%;
background: url(../images/bodyBG2.gif) 50% 150px no-repeat;