-1
A
回答
1
有一個簡單的例子。填寫表格。點擊「整頁」。預覽這裏摘錄壞作品
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.page {
width: 980 px;
margin: 0 auto;
height: 1200px;
border: 3px solid red;
}
.form {
top: 300px;
left: 20px;
display: block;
position: fixed;
border: 1px solid black;
}
/* The Modal (background) */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 15% auto;
/* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%;
/* Could be more or less, depending on screen size */
}
/* The Close Button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
<div class="page">
<div class="form">
<!-- Trigger/Open The Modal -->
<button id="myBtn">My form</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p>Some text in the Modal..</p>
</div>
</div>
</div>
</div>
+0
感謝您的時間和幫助 – akashi
相關問題
- 1. 可滾動的固定格
- 2. 固定側欄,可滾動內容
- 3. div可滾動固定格
- 4. 滾動時固定側欄
- 5. 頂部行和左側列凍結的可滾動HTML表格
- 6. 在固定側邊欄內滾動
- 7. 左側的UITableView滾動指示燈
- 8. 如何在離子中顯示左側的滾動條
- 9. 左側滾動條在CSS
- 10. 固定格內可滾動的div
- 11. 固定的右側div滾動
- 12. 兩個div,左側和流體格右側固定的div
- 13. 如何在屏幕左側顯示此字母滾動視圖
- 14. 顯示內嵌爲非頂部或左側固定位置
- 15. 如何使用滾動條在打開時顯示連續表單的左側
- 16. 左側的HTML5拖曳元素不顯示水平滾動條
- 17. CSS滾動固定側邊欄
- 18. 在d3左側顯示yax
- 19. 在magento左側顯示topmenu。?
- 20. 需要在小屏幕上向右流動UNDER左側(固定寬度右側,左側可變寬度)
- 21. 如何使隱式滾動查看器顯示在左側而不是右側
- 22. twitter bootstrap導航欄固定在左側?
- 23. jQuery無限滾動滾動固定格
- 24. Html表格固定垂直滾動
- 25. 滾動表格,保持標題固定
- 26. 數據表固定標題在滾動時顯示兩次
- 27. JScrollPane左側滾動條
- 28. 左側面板滾動
- 29. 固定到右側,即使左格是不存在的 - 引導
- 30. 滾動頂部固定格
您是否嘗試過的東西了嗎? – elementzero23