![](/img/trans.png)
[英]Using font-awesome and css, is it possible for a css change to alter the icon?
[英]Overlaying a font-awesome icon on an image in css
我試圖在圖像上覆蓋一個很棒的字體圖標,但是圖像是可見的,而圖標是不可見的。
<i class="fa fa-play-circle-o" aria-hidden="true"></i>
<img src="../images/tbt.jpg"></img>
i {
position: absolute;
z-index: 1;
top: 50%;
left: 50%;
}
img {
position: relative;
z-index: -1;
}
您可以在樣式中添加不透明度
i {
position: absolute;
z-index: 1;
top: 50%;
left: 50%;
opacity: 0;
}
img {
position: relative;
z-index: -1;
}
i:hover {
opacity: 1;
}
你沒有提到父 position。 將兩者包裝在任何塊標簽內,如 div、section 並相對於該塊級標簽分配樣式 position。
<div style="position:relative">
<i class="fa fa-play-circle-o" aria-hidden="true"></i>
<img src="../images/tbt.jpg"></img>
</div>
i {
position: absolute;
z-index: 1;
top: 50%;
left: 50%;
}
img {
position: relative;
z-index: -1;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.