5
我想添加一個半透明的統一圖層作爲div
元素的前景。什麼是最好的方式來做到這一點?透明前景
我想添加一個半透明的統一圖層作爲div
元素的前景。什麼是最好的方式來做到這一點?透明前景
你可以使用這個CSS ...
div.parent {
position: relative;
}
/* this div is a descendent of the div above */
div.child {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: .6;
background: #fff;
}
如果你想要鼠標事件去通過這個封面,添加pointer-events: none
到div.child
。
你標記它的jQuery,所以這個孩子元素通過jQuery添加...
$('div.parent').append('<div class="child" />');
'過濾器:α(不透明度= 60)'爲I.E. 8及以下。 – Jasper
我也是這麼做的;請注意,如果您需要選擇文本或想要捕捉事件,則必須跳過一些箍環。 –
@gregp:我更新了這個答案。謝謝。 – alex