@_nu/css-modal
Version: 
nu-system css modal
29 lines (28 loc) • 988 B
HTML
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../lib/index.css">
</head>
<body>
    <button type="button" onclick="showModal()">显示遮罩</button>
    <div id="domModal" class="nu_modal">
        <button type="button" class="nu_mask" title="遮罩"></button>   
        <button type="button" onclick="closeModal()">关闭遮罩</button>     
    </div>
    <script>
        function showModal(){
            console.log('show modal');
            document.getElementById('domModal').setAttribute('open', true);
        }
        function closeModal(){
            console.log('hide modal');
            document.getElementById('domModal').removeAttribute('open');
        }
    </script>
</body>
</html>