2016-12-07 51 views
0

我想为不是背景图片的图片添加黑色覆盖图。将黑色覆盖图添加到不是背景图片的图片wordpress帖子插件

我用下面的代码试过,但不起作用,

background-color: black, opacity: 0.5;

我也不能躺在顶部的另一个DIV因为它是一个插件,有时需要一点时间来加载

这是当前的CSS代码它

.flexslider .slides img { 
max-height: 700px; 
padding-bottom: 0px; 
width: 100%; 
background-color: black; 
margin-top: -2%; 
    background-color: rgba(0, 0, 0, 0.5) !important; 
+0

.flexslider .slides {背景色:RGBA(0,0,0,0.5)重要; }背景颜色添加到容器包含图像而不是图像本身 –

+0

请添加网址为更好地理解 –

+0

@VasimVanzara在我的本地 – tea93

回答

0

你应该使用伪元素 “:后”:

伪构件不能在IMG被使用,则必须用它在父DIV

.flexslider .slides{ 
    //blablabla 
    display : inline-block; 
    position : relative; 
} 

.flexslider .slides:after{ 
    position : absolute; 
    content : " "; 
    top : 0; 
    left : 0; 
    height : 100%; 
    width : 100%; 
    background-color : black; 
    opacity : 0.5; 
} 
+0

没有工作,嗯 – tea93

+0

HTTP:/ /plnkr.co/edit/eQCuFekdKwrBrm9U0gmg?p=preview,也许给我们你的html – grogro