How do I set transparency for background-image?

Source: Internet
Author: User
Title, now is not able to change the transparency of the image itself, the picture is written in Background-image CSS, do not know if there is a way to set his transparency?

div{    position:relative;        } div:after{    content: ";    Display:block;    width:100%;    height:100%;    Position:absolute;    top:0;    right:0;    bottom:0;    left:0;    Background:url (...);    opacity:0.5;}

Background map with PNG, with transparency.

The element sets transparency when the background, another element obscures to the top of the guest under its son, pretends to be the content of this element.

CSS's Opacity property allows you to set the transparency properties of the image.

#div {    background-image:url (img.png);    opacity:0.4;    Filter:alpha (opacity=40);/* for IE8 and earlier versions */}

Cannot change the transparency of the image itself, it can only change the transparency of the entire div to achieve a similar visual effect:
1.opacity Properties
2. Use the CSS3 filter-webkit-filter (as opposed to the previous IE filter) if compatibility allows.

Look at the implementation of this site

Opacity in CSS background images
Related Article

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: 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.