<!DOCTYPE html>
<html>
<head>
<title>W3.CSS(w3cschool.cn)</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
<link rel="stylesheet" href="https://7npmedia.w3cschool.cn/w3.css">
</head>
<div class="w3-container">
<h2>W3.CSS模式</h2>
<p>在此示例中,我们演示了如何通过单击模式框外部来关闭模式。</p>
<button onclick="document.getElementById('id01').style.display='block'" class="w3-button w3-black">打开</button>
<div id="id01" class="w3-modal">
<div class="w3-modal-content w3-card-4">
<header class="w3-container w3-teal">
<span onclick="document.getElementById('id01').style.display='none'"
class="w3-button w3-display-topright">×</span>
<h2>模式头部</h2>
</header>
<div class="w3-container">
<p>您有两种选择可以关闭此模式:</p>
<p>单击“ x”或单击模式之外的任何位置!</p>
</div>
<footer class="w3-container w3-teal">
<p>模式页脚</p>
</footer>
</div>
</div>
</div>
<script>
var modal = document.getElementById('id01');