-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. div可滚动固定格
- 3. 带固定标题和固定列的可滚动HTML表格
- 4. 顶部行和左侧列冻结的可滚动HTML表格
- 5. 如何在离子中显示左侧的滚动条
- 6. 左侧的UITableView滚动指示灯
- 7. 左侧滚动条在CSS
- 8. 固定格内可滚动的div
- 9. 显示内嵌为非顶部或左侧固定位置
- 10. 左侧的HTML5拖曳元素不显示水平滚动条
- 11. 在d3左侧显示yax
- 12. 在magento左侧显示topmenu。?
- 13. 如何使隐式滚动查看器显示在左侧而不是右侧
- 14. 滚动表格,保持标题固定
- 15. JScrollPane左侧滚动条
- 16. 固定到右侧,即使左格是不存在的 - 引导
- 17. 如何使DIV在CSS的x可滚动窗格中左侧流动?
- 18. 如何制作带有固定标题的可滚动表格
- 19. 左侧元素的固定边距
- 20. 在Visual Studio中左侧固定的活动选项卡
- 21. 风格选择显示左侧和右侧的值
- 22. 侧边栏,可以滚动,但主要内容固定
- 23. Android:在gridview中将滚动条的左侧设置为空格
- 24. 滚动固定标题会向下显示,然后显示为
- 25. UITextField文本不在左侧滚动
- 26. 如何在Tkinter中显示可滚动的电子表格?
- 27. 滚动到固定高度表中的活动表格行
- 28. 左分区固定,多个右分区可滚动
- 29. 两列分区布局:左=流体,右=固定和可滚动
- 30. 全高固定左侧边栏实现
您是否尝试过的东西了吗? – elementzero23