# html筆記 跳出式對話匡 ``` <style> .dialog{ position: fixed; top: 100px; left: 50%; transform: translate(-120px,0px); width: 240px; padding: 10px; border: 1px solid #0a53be; background-color: #0dcaf0; box-shadow: #79ff6c; display: none; } .dialog>.close{ position: absolute; top:2px; right: 2px; cursor: pointer; } </style> ``` **** ``` <button onclick="showdialog()">顯示資訊</button> <div id="dialog" class="dialog"> <div onclick="closedialog()" class="close">X</div> 對話內容在這 </div> ``` **** ``` <script> let dialog; window.onload=function (){ dialog=document.getElementById('dialog'); } function showdialog(){ dialog.style.display="block"; } function closedialog(){ dialog.style.display="none" } </script> ``` ![](https://i.imgur.com/s2C91zY.png)
{"metaMigratedAt":"2023-06-16T06:20:17.021Z","metaMigratedFrom":"Content","title":"html筆記","breaks":true,"contributors":"[{\"id\":\"a87d3e9f-9fd6-4c88-a65b-a905822fc1f4\",\"add\":988,\"del\":0}]"}
Expand menu