Pure CSS background half-transparent

Source: Internet
Author: User

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Style>
Body {Background: URL (http://www.google.com.hk/intl/zh-CN/images/logo_cn.png) 0 0 repeat ;}
* {Margin: 0; padding: 0 ;}
. Boxer {width: 600px; Height: 400px; overflow: hidden; margin: 0 auto; Border: 6px solid red ;}
. Opacity {
Height: 400px;
Background-color: rgba (0.5, 0,);/* The standard browser only needs this sentence */
Background-color: #000 \ 9;/* ie series */
Filter: alpha (opacity = 50);/* ie series */
/*
As a transparent background layer, you cannot have the position attribute. I don't know why...
.
Background-color: rgba (0.5, 0,). IE6 seems to be able to read a small part. Therefore, you can only write background-color: #000 after it, and then add a private hack of IE.
If you don't believe it, try it.
Background-color: #000; Background-color: rgba (0,0, 0, 0.5); filter: alpha (opacity = 50 );
IE6 will hurt you!
*/
}
. Boxerinner {position: relative;/* ie series */
Text-align: center; font-size: 24px; font-weight: 700; color: yellow ;}
</Style>
</Head>

<Body>
<P style = "font-size: 60px; color: #000; text-align: center; padding: 20px; font-weight: 700;"> CSS: transparent background color, the ultimate method of content opacity! Compatibility, ultimate. </P>
<Div class = "Boxer">
<Div class = "opacity">
<Div class = "boxerinner"> boxerinner </div>
</Div>
</Div>
</Body>
</Html>

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.