CSS background transparent text opaque

Source: Internet
Author: User

Set the transparency of an element: -moz-opacity:0.8; /* Set element Transparency  filter:alpha (opacity=80) in Firefox; /*ie using filters to set transparency   But when we set the transparency of the background on a label, we don't want the text image on that label to become translucent.   such as: <div><p> opaque </p></div> div{-moz-opacity:0.3;filter:alpha (opacity=30 ); background: #000; Width:500px; height:500px;color: #F30; font-size:32px; Font-weight:bold; }  can clearly see the text is also translucent, this is the effect we do not want to see.   I used to be the absolute location of the method to solve this problem, that is, the present p is not a sub-element of the Div.  <div></div> <p> opaque </p>  The translucent effect of the div will not affect the element p. Finally, the p is positioned to the desired location.   But a lot of times this kind of label is not very reasonable, it is possible to waste a few more tags.   The following method can solve the above problem:  div{background:rgba (0,0,0,0.2) None repeat scroll!important;/* Achieve FF background transparent, text opaque */ Background: #000; Filter:alpha (OPACITY=20);/* Implement IE background transparent */  width:500px; height:500px; Color: #F30; font-size:32px; Font-weight:bold;}  div p{position:relative;} /* Implement IE opaque */  Firefox we can use the RGBA color directly to solve the problem of sub-label with translucent, but IE is not able to support very well.   So we do not want to be transparent label set a positioning property, the problem can be solved.

Original link: http://blog.163.com/l_lihanyu/blog/static/12003272320123185372127/

CSS background transparent text opaque

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