0

嗨,是否可以将 bg 图像放置在页面中心的固定位置?

4

3 回答 3

1

对的,这是可能的。使用以下代码。

body {
  background: url("yourimage.gif") 50% 50% no-repeat;
}
于 2013-09-15T08:40:50.697 回答
0

是的,

{
background-position: center;
background-repeat: no-repeat;
}
于 2013-09-15T08:31:19.803 回答
0

这个怎么样:

小提琴

div
{
    position:fixed;
    top: 50%;
    left:50%;
    background: url(http://placehold.it/50x50) no-repeat;
    width: 50px;
    height:50px;
   /*margin: offset here*/ 
}

在这里,图像的左上角位于页面的中心。您可以通过添加边距来抵消这一点。

因此,在您的情况下,您需要将其从中心偏移 100px - 所以添加margin-left:100px

于 2013-09-15T08:33:18.600 回答