css为图片添加一层蒙版并在上层显示文字等

效果图:

css为图片添加一层蒙版并在上层显示文字等

代码如下:

<div class="row" style="100%; position:relative;z-index:1;margin:0 auto; background: #000;">
    <img src="~/images/touxiang.jpg" style="100%; opacity:0.6; filter: alpha(opacity=60);"/>
    <div style="100%;position:absolute;z-index:2;top:50%; text-align:center;">
        <h2 style="color:#fff">文字浮动在图片上方</h2>
    </div>
</div>