![](/img/trans.png)
[英]How can I create transparent divs that have a picture as background on an otherwise black background?
[英]How can I make a scrolling DIVs background transparent?
我正在嘗試使半透明圖像向上滾動以顯示其下方的另一張圖像。
到目前為止,我已經將頂部圖像向上滾動而固定圖像位於下方,但我無法弄清楚如何讓頂部圖像的透明部分顯示下方的固定圖像。
我確保頂部圖像是透明的,並通過將頂部幻燈片背景顏色設置為紅色來測試它,這工作正常,但將其設置為透明仍然顯示為白色。
在 CSS 中,我已經把這兩個都無濟於事:
background-color: transparent;
background-color: rgba(0, 0, 0, 0);
你能告訴我我做錯了什么或給我一種替代方法來實現這一目標嗎?
謝謝。
在 jbutler483 的小提琴的幫助下,我做了你想要的。 你需要opacity
使圖像透明和position: absolute;
刪除白色背景。
使用以下代碼更改您的 slide1'css:
#slide_1 {
background-image: url("http://i.imgur.com/TIaK19Z.png");
background-size: 120%;
background-color: rgb(0, 0, 0, 0.2);
position: absolute;/* To remove white background */
top: 0;
opacity:0.8;/* To make the top image transparent */
left: 0;margin-bottom:100vh;
}
您可以根據需要更改不透明度值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.