Use CSS to simulate the effect of Vista glass.

Source: Internet
Author: User

Recently, the effect of Windows Vista glass has been imitated by peers in the world. The younger brother is not talented. He also posted his own remark.

First, prepare two background images. One is a normal image, and the other is a blur of the normal image.

Use the background definition in CSS to set the normal image as the background of the body node (note that the margin of the body must be set to 0, otherwise the blurred image and the normal image will have a location offset ), set the property of background-attachment to fixed.
Next, set the style on the image that needs to apply the frosted glass effect, and set the blurred image as the background of the required node, similarly, set the attribute of background-attachment to fixed (the location of the required node is preferably absolute ).
In this way, the effect of imitating Windows Vista is basically complete.
-------------------------------------
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML xmlns ="
Http://www.w3.org/1999/xhtml>
<Head>
<Style type = "text/CSS">
*{
Margin: 0px;
Padding: 0px;
}
Body {
Background-image: URL (./back.jpg );
Background-Attachment: fixed;
}
Div. Glass {
Background-image: URL (./glass.jpg );
Background-Attachment: fixed;

Position: absolute;
Top: 100px;
Left: 200px;
Width: 300px;
Height: 200px;
Overflow: hidden;
}
</Style>
</Head>
<Body>
<Div class = "Glass"> </div>
<Div style = "width: 3000px; Height: 3000px;"> </div>
</Body>
</Html>

-------------------------------------
PS: for the time being, ie6is not supported. If you want to use back.jpg as the original background, glass.jpg uses the original background PS as the frosted glass. The size is the same as that of the original image.

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.