我一直在构建一个视差网页。当我将前景图像滚动到背景图像上时,png 具有白色背景,而不是预期的透明背景。我使用 Bootstrap 作为网站架构,并使用固定背景作为背景图像,即(不)透明的 png 向上滚动的图像。如有任何建议,谢谢。
我尝试了背景颜色:透明!重要;实际上,在网站上的每个元素上,这个 png(或它包含 div)仍然显示为白色。
测试代码可以在这里找到:https://marbis43.dreamhosters.com/test.html
我已经解决了。
我将第一个 div 从将绿色框作为背景图像更改为包含图像。
#bootstrap-overrides .jumbotron {
/* background-image: url(../images/green-box.png); */
background-position: top center;
background-size: cover;
background-repeat: no-repeat;
height: 100vh;
width: 100%;
margin: 0;
position: fixed;
z-index: -1;
padding: 0;
}
<div class="parallax jumbotron">
<img src="images/green-box.png" alt="bg image" width="100%">
</div>