CSS changes background transparency "go"

Source: Internet
Author: User

Transparency often produces good web visuals, with CSS transparent code compatible with mainstream browsers:

. transparent_class {
Filter:alpha (OPACITY=50);
-moz-opacity:0.5;
-khtml-opacity:0.5;
opacity:0.5;
}

Several of the above properties are:

    • opacity:0.5; This is the most important because it is a CSS standard. This property supports Firefox, Safari, and Opera.
    • Filter:alpha (opacity=50); This is set for IE6, the value is 0-100, the other three 0 to 1.
    • -moz-opacity:0.5; This is to support some of the older versions of Mozilla browser.
    • -khtml-opacity:0.5; This is to support some of the older versions of the Safari browser.

CSS Transparency Inheritance Issues

The transparency property of CSS involves an inheritance problem, and when you set the transparency for a parent element, the child element automatically inherits its transparency, which makes it invalid for you to specify a transparency of 1 for the child element.

The first method is to specify a relatively deeper color for the text book element. In other words, when the child element inherits the transparency, the resulting text color is exactly what you want.

The premise is that this color also has the possibility of deepening, and the need for detailed calculations of color and transparency values.

The second method – a question about the degree of transparency inheritance . The principle is simple, add an empty element as a transparent layer, and the element that does not want to be transparent but implements the overlay effect is a sibling element. The parent element uses

Position:relative positioning; Two sub-elements use position:absolute positioning to achieve coverage.

Example code:

HTML code:
  1. <div class="Div3″><div class=" Div4″></div> There's no transparency in the text pictures.
  2. <div class="Div2″> Picture </div>
  3. </div>
CSS Code:
  1. Body {
  2. background-image: url (http://www.css88.com/demo/jQuery/blockSlide/2009-02-04_105247.png);
  3. background-repeat: repeat;
  4. }
  5. . div2{ Width:100px; height:100px; background: URL (http://www.css88.com/images/testbok.png)}
  6. . div3{ Width:200px; height:200px; position:relative; margin-top:10px}
  7. . div4{ Position:absolute; top:0; height:200px; width:200px; z-index:-1;  background:#FFFFFF; Filter:alpha (opacity=70); opacity:0.7;}

"Reprint" http://blog.sina.com.cn/s/blog_66e0d37601015ncl.html

CSS changes background transparency "go"

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.