Implementation of the CSS mask layer and the CSS Mask Layer
I accidentally found that I had written a CSS mask layer. Although this thing has no technical content, if I leave the company and then encounter such problems, it may take some time to find the materials. So I decided to write it down.
Run the Code directly.
Step 1: html code:
Java code
- <Div id = "popDiv" class = "mydiv" style = "display: none;">
- <Div style = "text-align: right">
- <A href = "javascript: closeDiv ()">
- </A>
- </Div>
- <Div id = 'orgnote' class = "note_div"> </div>
- </Div>
- <Div id = "bg" class = "bg" style = "display: none;"> </div>
- <Div style = "margin-left: 180px;">
- <A title = "instant registration and return information" style = "margin-left: 0px; # FFFF66; font-size: 16px; text-decoration: underline! Important; "href = 'javascript: showDiv ($ {doctor. orgId}) '> Registration Notice </a>
- </Div>
The above code consists of three parts. popDiv indicates the pop-up layer, which is displayed when you click the registration notice link.
Bg indicates the mask layer, that is, the content behind the layer is hidden when the pop-up layer is displayed. The link is displayed.
The CSS classes of these three parts are as follows:
Css code
- . Mydiv {
- # FCF4EA;
- Border: 1px solid # D00000;
- Text-align: center;
- Font-size: 12px;
- Z-index: 99;
- Left: 30%;/* FF IE7 */
- Top: 20%;/* FF IE7 */
- Margin-left:-150px! Important;/* FF IE7 this value is half of its width */
- Margin-top:-60px! Important;/* FF IE7 this value is half of this height */
- Margin-top: 0px;
- Position: absolute;/* FF IE7 */
- }
- . Note_div {
- Width: 700px;
- Height: 400px;
- Overflow: scroll;
- Text-align: left;
- Padding: 15px;
- }
- . Bg {
- # Ccc;
- Filter: alpha (opacity = 50);/* IE */
- Opacity: 0.5;/* FF */
- Z-index: 1;
- Position: absolute;/* IE6 */
- }
The most important part is that the bg mask layer needs to cover full screen. This is difficult to solve, so JQuery is used to solve it, that is, when the page is initialized, set the bg size:
Js Code
- $ (Function (){
- $ (". Bg"). width ($ (document). width ());
- $ ('. Bg'). height ($ (document). height ());
- Parameters ('.bg').css ('left', 0 );
- Certificate ('.bg'0000.css ('top', 0 );
- });
With the above foundation, you only need to set the data and mask layer to be displayed by clicking the link via ajax callback, as shown below:
Js Code
- Function showDiv (orgId ){
- RegAsyncController. getOrgNotes (orgId, function (data ){
- $ ("# OrgNote" 2.16.html (data );
- $ ("# Bg"). show ();
- $ ("# PopDiv"). fadeIn (1000 );
- });
- }
- Function closeDiv (){
- $ ("# PopDiv"). fadeOut (1000, function (){
- $ ("# Bg"). hide ();
- });
- }
This process is actually relatively simple, but I do not often engage in page things, so I can't remember a few things of CSS. I just need to know something and write it down.