要創(chuàng )建一個(gè)帶樣式的何寫(xiě)彈窗,可??以使用HTML、樣彈窗CSS和JavaScriptヽ(′ー`)ノ,何寫(xiě)以下是樣彈窗一個(gè)簡(jiǎn)單的示例:
(圖片來(lái)源網(wǎng)絡(luò ),侵刪)1、何寫(xiě)創(chuàng )建一個(gè)HTML文件,樣彈窗例如popup.html,何寫(xiě)并添加以下內容:
<!DOCTYPE html&g??t;<html lang="en"><(?????)head> <??;meta charset="UTF8"> <meta name="viewport" content=&qu┐(′д`)┌ot;width=devicewidth,樣彈窗 initialscale=1.0"> <title>帶樣式的彈窗</title> <style> /* 彈窗背景 */ .popup { display: none; position: fixed; zindex: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; backgroundcolor: rgba(0, 0, 0, 0.4); } /* 彈窗內容 */ .popupcontent { backgroundcolor: #fefefe; margin: 15??% auto??; paddin??g: 20px;?? border: 1px solid #888; width: 80%; } /* 關(guān)閉按鈕 */?? .close { color: #aaa; float: right; fontsize: 28px; fontweight: bold; } .close:hover, .close:??focus { color: black; textdecoration: none; cursor: pointer; } </style></(╬ ò﹏ó)head><body><!彈窗結構 ><div id="myPopup" class="popup"> <div class="popupcontent"> <span class="close">×</span> <h2>彈窗標題</h2> <table> <tr> <th>小標題1</th> <td>單元表格內容1</td> </tr> <tr> <t??h>小(xiao)標題2</th> <td>單元表格內容2<ヽ(′?`)ノ;/td> </??tr> </table> </div></div>???<??;script> // 獲取彈窗元素 var popup = document.get??Eleヽ(′ー`)ノmentヽ(′▽?zhuān)?ノById("myPopup"); // 獲取關(guān)閉按鈕元素 var closeBtn = document.getElementsByClassName(&qu( ?ω?)ot;close")[0]; // 顯示彈窗 function showPopup() { popu??p.style.display = &qu??ot;block"; } // 隱藏彈窗 function hidePopup() { popup.style.display = "none(′?`*)"; } // 當用戶(hù)點(diǎn)擊關(guān)閉按鈕時(shí),隱藏彈窗 closeBtn.onclick = function() { hidePopup(); } // 當用戶(hù)點(diǎn)擊彈窗外的何寫(xiě)區域時(shí),隱藏彈窗 window.onclick = function(event) { if (event.target == popup) { hidePopup(); } }</script></body></html>2、樣彈窗保存文(wen)件后,何寫(xiě)用瀏覽器打???開(kāi)popup.html,樣彈窗你將看到一個(gè)帶有樣式的何寫(xiě)彈窗,點(diǎn)擊彈窗外的樣彈窗區域或關(guān)閉按鈕可以關(guān)閉彈窗。
電話(huà):17730087525
網(wǎng) 址:http://www.hunqingrc.com/
地 址:上海市浦東新區66號