固定中心底部背景位置

时间:2015-08-24 16:28:39

标签: css

我想我可以用jQuery做到这一点,但我只尝试使用CSS,我试图定位一个固定在页面中心和底部的背景图像。我的div是1024宽,而高度取决于内容。我希望背景图像保持居中,直到浏览器的大小低于1024宽,此时我希望将背景图像设置在左侧。(保持正确的背景大小。

这是我迄今为止在代码中所拥有的。

.scroll-stuff{
    background-image:url(imgs/leaderboard/percentages.png);
    background-size:100 100;
    background-repeat:no-repeat;
    width:1024px;
    margin: 0 auto;
    position:relative;
    background-attachment:fixed;
    background-position:center bottom;
}

1 个答案:

答案 0 :(得分:0)

使用媒体查询。如果您只是尝试更改图像的位置,则以下内容将起作用

@media all and (max-width: 1024px) {
    .scroll-stuff {
        background-position:left bottom;
    }
}