背景图片,但具有不透明度css

时间:2022-06-17 19:56:55

I have an issue with my background not covering the whole site from top to bottom. I know what causes the problem, but as to fixing it I am unsure. My CSS looks like this:

我的背景问题不是从上到下覆盖整个网站。我知道造成这个问题的原因,但至于修理它我不确定。我的CSS看起来像这样:

#background-img{
    display: block;
    position: absolute;
    background-image: url(http://images2.alphacoders.com/778/77840.jpg);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center; 
    width: 61.8%;
    margin-left: 19.1%;
    height: 100%;
    opacity : .3;
}

The problem seems to happen where the at the point where I add height. But I am not allowed not to have it there as there wont be anything to have a background for. The problem initially is that I need opacity on the image, so I can't just make it cover the wrapper either, as that will give the whole site opacity, not just the background.

这个问题似乎发生在我增加高度的地方。但我不允许不在那里,因为那里没有任何背景。最初的问题是我需要在图像上使用不透明度,所以我不能让它覆盖包装器,因为这将使整个网站不透明,而不仅仅是背景。

1 个解决方案

#1


0  

If anyone ever should read this post. I found a solution. I just moved the whole background-image div to the top of the very wrapper div, and made the position fixed, instead.

如果有人读过这篇文章。我找到了解决方案。我只是将整个背景图像div移动到非常包装div的顶部,并将位置固定。

#1


0  

If anyone ever should read this post. I found a solution. I just moved the whole background-image div to the top of the very wrapper div, and made the position fixed, instead.

如果有人读过这篇文章。我找到了解决方案。我只是将整个背景图像div移动到非常包装div的顶部,并将位置固定。