CSS for transparent background, text opaque (compatible with each browser)

Source: Internet
Author: User
In newer browsers such as Ff/chrome, you can use the CSS properties Background-color Rgba to easily achieve background transparency, while text remains opaque. The Ie6/7/8 browser does not support RGBA, only the use of IE's exclusive filter filter:alpha to achieve, but this writing will also make the text transparent, so only in the transparent container child nodes (except the text node) set position: Relative can not inherit the transparent filter of its parent element, the code is as follows:

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
<HTMLxmlns= "http://www.w3.org/1999/xhtml">
<Head>
<Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />
<title>Web Developer Network-www.admin10000.com</title>
<styletype= "Text/css">
. Warp{background:#eee URL (back.jpg) no-repeat left top;width:440px;Height:400px;Border:1px solid #ccc;}
. Content{width:180px;Height:260px;margin:0px Auto;padding:30px 30px;background:Rgba (255, 255, 255, 0.6)!important;
Filter:Alpha (opacity=60);background:#fff; /*use IE-specific filters for IE background transparency*/ }
. Content P{position:relative;} /*realize IE text opaque*/
</style>
</Head>
<Body>
<Pclass= "Warp">
<Pclass= "Content"><P>admin10000.com is a web Developer Learning Communication Essentials website. Admin10000.com is a web Developer Learning Communication Essentials website. Admin10000.com is a web Developer Learning Communication Essentials website. Admin10000.com is a web Developer Learning Communication Essentials website. Admin10000.com is a web Developer Learning Communication Essentials website. Admin10000.com is a web Developer Learning Communication Essentials website. </P></P>
</P>
</Body>
</HTML>

The above code is tested in Ie6.0+/ff3.0+/opera10+/chrome/safari

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.