//js代碼
function overlay() {
var el = document.getElementById('modal-overlay');
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
function showModal() {
var el = document.getElementById('modal-overlay');
el.style.visibility = "visible";
}
模態(tài)框的美化
<!-- html代碼 -->
<!-- 遮罩層 -->
<div id="openModal" class="modalDialog">
<div> <!-- 對話框 -->
<a href="#close" title="Close" class="close">X</a> <!-- 關(guān)閉按鈕-->
<h2>Modal Box</h2>
<p>This is a sample modal box that can be created using the power of CSS3.</p>
<p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div>
</div>