html add mask effect

王林
Release: 2020-08-26 16:31:31
forward
4143 people have browsed it

html add mask effect

The div css method is used here. The images being loaded are animations downloaded from the Internet. You can modify them according to your needs.

(Recommended tutorial: html tutorial)

Implementation code:

<!DOCTYPE html>
<html>
<head>
    <title>DIV CSS遮罩层</title>
    <script language="javascript" type="text/javascript">
        function showdiv() {
            document.getElementById("bg").style.display ="block";
            /* document.getElementById("show").style.display ="block";*/
        }
        function hidediv() {
            document.getElementById("bg").style.display =&#39;none&#39;;
            /*document.getElementById("show").style.display =&#39;none&#39;;*/
        }
    </script>
    <style type="text/css">
        #bg{ display: none;  position: absolute;  top: 0%;  left: 0%;  width: 100%;  height: 100%;  background-color: black;  z-index:1001;  -moz-opacity: 0.7;  opacity:.70;  filter: alpha(opacity=70);}
        #show{display: none;  position: absolute;  top: 25%;  left: 22%;  width: 53%;  height: 49%;  padding: 8px;  border: 8px solid #E8E9F7;  background-color: white;  z-index:1002;  overflow: auto;}
        /*遮罩图片居中显示*/
        .zhezhao{
            position: absolute;
            top:50%;
            left: 50%;
            transform: translate(-50%,-50%);
        }
    </style>
</head>
<body>
<input id="btnshow" type="button" value="Show" onclick="showdiv();"/>
<div id="bg">
    <img  class="zhezhao" src="img/timg.gif" alt="html add mask effect" >
</div>    <!-- 遮罩层  -->
<div id="show">测试
    <input id="btnclose" type="button" value="Close" onclick="hidediv();"/>
</div>
</body>
</html>
Copy after login

Effect:

html add mask effect

The above is the detailed content of html add mask effect. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!