我有一個父級div.parent,背景色爲白色,div爲圖像。當父級具有背景色時,圖像不顯示爲線性漸變
我設置div.img容器
我需要的是有一個與背景色的容器上的線性梯度:白色,並且圖像上的背景線性梯度。我需要2個「父母」。我不知道我錯過了什麼,它工作正常,當我只有一個DIV ..
.parent{
background-color:grey;
}
.img-container{
height:200px;
width:200px;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.30) 0%, rgba(0, 0, 0, 0.75) 100%);
margin:auto;
}
.my-img{
display:block;
position:relative;
width:200px;
height:200px;
z-index:-1;
}
<div class="parent">
<div class="img-container">
\t <img class="my-img" src="http://image.noelshack.com/fichiers/2016/05/1454345014-capture-d-ecran-2016-02-01-a-17-43-28.png">
</div>
</div>
的圖像沒有顯示,因爲這條線的:。我-IMG {z索引:-1; }你是否想要在圖像頂部有漸變並仍然可以看到圖像? – cocoa
多數民衆贊成那是正確的,我只需要在圖像上的梯度,但我發現我的答案謝謝:) – teddym