"Go" use Background-color to add matte effects to the background map using CSS

Source: Internet
Author: User
Tags set background

A div set background-color and background-image, color is under the IMG layer, can not achieve the matte effect, so you need to create a DIV as its sub-div, and then set the sub-div background color, There are two ways of doing this:

First, the code is as follows:

 CSS:. wrap{position:relative; Background:url (i/pic4.jpg) no-repeat; -webkit-background-size: -%; Background-size: -%;}. Warp-mask{
height:100%;
width:100%; Background:rgba (0,0,0,.4);} HTML: <divclass="Wrap"> <divclass="Wrap-mask"></div></div>

The second, through the after pseudo-element settings, the code is as follows:

 CSS:
. wrap{position:relative; Background:url (i/pic4.jpg) no-repeat; -webkit-background-size: -%; Background-size: -%;}. Wrap-mask:after{Position:absolute; Top:0; Left:0; Content:""; Background-Color:yellow; Opacity:0.2; Z-index:1; Width: -%; Height: -%;}

HTML: class="wrap">    class="Wrap-mask"></div></div>

Reference article Source: 53219367

"Go" use Background-color to add matte effects to the background map using CSS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.