- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我找到了如何创建模态的信息 https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal2
事实上我没有java脚本知识
我需要你帮助我在一个 .html 页面中创建 4 或 5 个 JavaScript 模式
我已经尝试过这段代码:
<script>
// Get the modal
var modal = document.getElementById('myModal');
var modal = document.getElementById('myModal2');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
var btn = document.getElementById("myBtn2");
// 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";
}
}
</script>
<style>
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
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 */
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}
/* Add Animation */
@-webkit-keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
@keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
/* The Close Button */
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.modal-body {padding: 2px 16px;}
.modal-footer {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
<h2>Animated Modal with Header and Footer</h2>
<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Modal Hecccccccccccccader</h2>
</div>
<div class="modal-body">
<p>Some text in the Modal Body</p>
<p>Some other cccccccccccctext...</p>
</div>
<div class="modal-footer">
<h3>Modal ccccccccccccccFooter</h3>
</div>
</div>
</div>
<!-- Trigger/Open The Modal -->
<button id="myBtn2">Open Modal</button>
<!-- The Modal -->
<div id="myModal2" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Modaldddddddddddd Header</h2>
</div>
<div class="modal-body">
<p>Some textdddddddddddddddddd in the Modal Body</p>
<p>Some otherdddddddddddddddddddd text...</p>
</div>
<div class="modal-footer">
<h3>Modal Footer</h3>
</div>
</div>
</div>
*!--- ---->
结果这些按钮都不起作用或无法正确显示
最佳答案
Hello 模态正在使用 ID,我们不能使用相同的 ID,因此,我们需要像这样为每个模态使用特定变量并删除 <script>
来自片段
// Get the modal
var modal = document.getElementById('myModal');
var modal2 = document.getElementById('myModal2');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
var btn2 = document.getElementById("myBtn2");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
var span2 = document.getElementsByClassName("close2")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
btn2.onclick = function() {
modal2.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks on <span> (x), close the modal
span2.onclick = function() {
modal2.style.display = "none";
}
// Get the modal
var modal = document.getElementById('myModal');
var modal2 = document.getElementById('myModal2');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
var btn2 = document.getElementById("myBtn2");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
var span2 = document.getElementsByClassName("close2")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
btn2.onclick = function() {
modal2.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks on <span> (x), close the modal
span2.onclick = function() {
modal2.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";
}
if (event.target == modal2) {
modal2.style.display = "none";
}
}
/* The Modal (background) */
.modal {
display: none;
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
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);
}
/* Modal Content */
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}
/* Add Animation */
@-webkit-keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
@keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}
/* The Close Button */
.close,.close2 {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus,.close2:hover,
.close2:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.modal-body {padding: 2px 16px;}
.modal-footer {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
<h2>Animated Modal with Header and Footer</h2>
<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Modal Hecccccccccccccader</h2>
</div>
<div class="modal-body">
<p>Some text in the Modal Body</p>
<p>Some other cccccccccccctext...</p>
</div>
<div class="modal-footer">
<h3>Modal ccccccccccccccFooter</h3>
</div>
</div>
</div>
<!-- Trigger/Open The Modal -->
<button id="myBtn2">Open Modal</button>
<!-- The Modal -->
<div id="myModal2" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close2">×</span>
<h2>Modaldddddddddddd Header</h2>
</div>
<div class="modal-body">
<p>Some textdddddddddddddddddd in the Modal Body</p>
<p>Some otherdddddddddddddddddddd text...</p>
</div>
<div class="modal-footer">
<h3>Modal Footer</h3>
</div>
</div>
</div>
关于javascript - 带有页眉和页脚的双动画模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47117794/
我想将页 footer 分放在文档的每一页上,除了第一页。 我通过扩展 TCPPDF 类并覆盖其页脚方法来创建我的自定义页脚。 然后根据文档并使用以下示例,我明白我应该使用 SetPrintHeade
我的页面分为 3 个部分。 页眉 主要 和页脚。 header 固定在顶部,大小为 109px,边框高 6px,因此 main 到顶部的边距为 109px。我希望 main 扩展到 heade
我正在构建一个网站,其中每个页面都有一个 , 和一个 . 据我了解,应用程序的入口点应包括这三个组件,并且应根据用户所在的路线呈现一个或多个附加组件。 我已经像这样构建了我的入口点: App.js
谁能告诉我为什么Footer出现在页面顶部,而我看不到Header或LayoutDiv9? 这是我添加的第二个 CSS 表,第一个是自动添加的 Fluid Grid Layout CSS 表,我根本没
我的应用程序中有这个页面: http://actibities-uniongr.rhcloud.com/pages/view-demo 如果您将浏览器的窗口缩短到小于 1000 像素并水平滚动,您会看
这个问题已经有答案了: Python command line interaction library? (3 个回答) 已关闭10 年前。 如何创建一个包含静态页眉和页脚的 Python 脚本,如下
我正在努力为我们的 Mediboard 元素提供完整的 HTML 页眉/页脚打印功能。 从长远来看,我知道 CSS3 页面媒体模块将满足我的需求,但这至少需要两三年时间。 所以我试着让它与 CSS2
我可以在每页上打印页眉,但我不熟悉打印页边距。我认为 @page css 可以工作,但它似乎不会影响页边距。如果我在正文上设置边距,它在第一页上有效,但后续页面默认从上边距开始,将页眉放在文本顶部。
有什么办法,就像 WordPress 一样,创建 header.php、theme-file.php 和 footer.php,然后使用钩子(Hook)将它们组合起来?对我来说仍然复制皮肤文件似乎
我正在努力解决以下问题。我有一个 UICollectionView,它的布局的页眉和页脚引用大小设置为一个值(比如 40.0)。当我删除/插入单元格并且集合 View 位于页眉和页脚不在屏幕上的位置时
我是 javascript 新手。我想使用 ajax 加载我的网站主模板文件(页眉、页脚、侧边栏)。我的布局文件如下所示。 布局.php header(); $ret .= $app->side
这是我的代码。内容图像曾短暂地工作,但现在消失了。 试图让Header只出现在页面顶部,图片高度为1000px。页面底部的页脚,图像高度为 1000px。内容图像需要重复以适合内容。这是一个博客,所以
我正在尝试将以下图像添加为网站内容的背景: http://webbos.co/vibration/wp-content/themes/vibration-child-theme/images/back
如何更改样式表中的页眉/页脚文本颜色? 我试过了,没有结果: footer: { parent: normal, alignment: TA_CENTER, textColor: red
我有以下 HTML,它有一个页眉、一个可滚动的内容和一个页脚,并且工作正常。 我想添加到此 HTML 的是一个包装所有三个 div 的表单,问题是一旦我用标签包装 div,布局就会中断。有什么建议吗?
我使用 jQuery 创建了具有不同状态的页眉和页脚导航。单击页脚导航时,我在更新页眉导航时遇到问题。例如,当用户单击页脚导航中的列表 1 时,我希望页眉导航也更新为相同的选择。我包含了一个 jsfi
我需要创建一个网页,其中包含正常页眉 + 粘性页脚 + 垂直拉伸(stretch)的流体内容。但是,这些位置不能是绝对的,因为我需要 780 像素的页面最小高度。 我设法使用表格完成了此操作,但我真的
我知道这可能是一件非常简单的事情,但除了很棒的 Stack Overflow 社区之外,我不知道有谁可以帮助我解决我的问题。我已经有一段时间没有在这种程度上使用 HTML/CSS 了。 我正在尝试为我
我前段时间做了一个wordpress网站。我今天刚刚看了一眼,由于某种原因,这个标志已经向东传播了。它已经厌倦了 clearfix 的 float 、文本对齐和边距:0 自动。谁能告诉我发生了什么,或
我需要帮助创建包含#header、#footer 和#main 的div 的代码。我只是不确定它在代码中的位置。我创建了一个带有 css 样式表的简单 html 页面。我并不是要任何人为我编写代码,因
我是一名优秀的程序员,十分优秀!