我想在我的网站中制作视差效果,但是我无法将 DIV 元素的背景设置为透明,尽管使用了 background-color: transparent
.
基本上,我只想在 DIV 中显示文本,并删除背景色。
通过使用 W3School..
body, html {
height: 100%;
}
.parallax {
/* The image used */
background-image: url('http://www.zastavki.com/pictures/originals/2013/Photoshop_Image_of_the_horse_053857_.jpg');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.parallax2 {
/* The image used */
background-image: url('http://www.qygjxz.com/data/out/114/4676052-image.png');
/* Full height */
height: 100%;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Turn off parallax scrolling for tablets and phones. Increase the pixels if needed */
@media only screen and (max-device-width: 1024px) {
.parallax {
background-attachment: scroll;
}
}>
<div class="parallax"></div>
<div style="height:100px;background-color:transparent;font-size:36px">
Some text goes here, need to try to make the background of this transparent? Any ideas?
</div>
<div class="parallax2"></div>
谢谢
最佳答案
如果您想将背景颜色设置为透明,您可以执行所有这些操作。
背景颜色:;
背景颜色:透明;
背景色:rgba(0, 0, 0, 0);
但在这种情况下,您需要在此处设置不同的位置是我希望这就是您要找的代码
<div style="height:100px;font-size:36px; border:1px solid red; position: absolute;">
Some text goes here, need to try to make the background of this transparent? Any ideas?
</div>
关于html - 使div元素背景对背景图片CSS透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45265233/