Darken image overlay and add text over it in CSS

后端 未结 4 1861
甜味超标
甜味超标 2021-01-21 06:07

How would I darken (add a semi-transparent overlay) and add text to this image (but centred horizontally and vertically) as below:

4条回答
  •  误落风尘
    2021-01-21 06:27

    html

    fsfsfsssf

    css

    body{
        margin:0px;
    }
    #back{
        width:100%;
        height:500px;
        background: url("http://luxurylaunches.com/wp-content/uploads/2014/05/uber-london.jpg") no-repeat;
        background-size:contain;
    }
    #mask{
        position:relative;  
        width:100%; 
        height:500px; 
        background:rgba(255,255,255,0.5); 
    }
    #text{
        position:absolute;
        top:230px;
        left:48%;
    }
    

    Fiddle: http://jsfiddle.net/6jf0nxd5/20/

提交回复
热议问题