Jquery translucent mask effect Summary

Source: Internet
Author: User

The road from academic science is getting farther and farther away recently !!

What we want to summarize today is to implement a translucent mask effect. Click a button on the page to immediately display a part in the center of the screen, and the area outside the part is covered with a translucent mask. Click the mask area. The central part disappears and the page is restored to its original shape.

First, let's talk about the simplest implementation method. Prepare two divs. One is the canvas <div class = "bg"> </div>, the other is the widget <div class = "content"> </div> to be displayed in the center of the screen. You can define what to display in the content. It can be an image, a chart, or a video. Then add the effect to make it work.

1. Now that you have clicked the button to hide the original webpage, set the display priority for the two divs: z-index, set content to 3, and bg to 2.

2. If the image is translucent, add a color to the bg mask: background: #000.

3 At the beginning, they were hidden: display: none. after an event is triggered, it is displayed. This requires the jquery statement: $ ('. bg '). fadeIn (200 );$ ('. Content'). fadeIn (400 );

Well, it's almost the same. It's very simple. The complete code is as follows:

Click here and the body of the webpage is blablabla. Welcome to Sina Weibo! Believe in music, believe in May

This kind of original ecosystem implementation is easier. Some plug-ins can provide similar functions. Such as fancybox: http://fancybox.net/

The demo in fancybox is very nice. After all, it is professional. If you are interested, please take a look. The interface is also very simple. I learned it in just a few minutes.

If you want to pop up a dialog box, you can try jQuery UI: http://jqueryui.com/dialog/. There are several forms of dialog box above.

There are also some plug-ins, such as pop easy and thick box. But if you want to use plug-ins, it will be troublesome. Some plug-ins are charged, so you will be given a trial period of several days. Some plug-ins cannot be said when they will not be updated, which will affect the compatibility of your web pages. So, I 'd better use my first recommendation method.

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.