我想在我的網站內製作視差效果,但是我無法將DIV元素的背景設置爲透明,儘管使用了background-color: transparent
。使div元素背景對背景圖像透明CSS
本質上,我想單獨顯示DIV中的文本,並刪除背景顏色。
通過使用W3Schools的..
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>
謝謝
該div應該站在容器的一個範圍內,否則你們之間有100px的差距。添加一個BG到身體找出.... https://codepen.io/gc-nomade/pen/QMWLGL –