- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个模态,其中我在模态窗口打开时使 body 背景变得模糊,它与一组 html 代码完美配合,但与其他 html 代码有问题(当使用的 css 和 JavaScript 完全相同时,对我来说听起来很奇怪)
问题是当模态窗口打开时(在非工作 html 代码中),模态窗口和背景一起变得模糊并永远保持这样......在其他 HTML 代码中它工作完美。一旦模式打开,只有背景变得模糊,当窗口关闭时背景变得正常 - 一切都很好
所以首先我附上可以很好地协同工作的代码 - Html、css 和 JavaScript
在帖子的底部,我将发布指向不同 html 代码的链接,其中此功能由于某些未知原因似乎无法正常工作(以便任何人都可以轻松比较和调试问题)
JavaScript
let open_modals = [];
$(function() {
// Get the button that opens the modal
// read all the control of any type which has class as modal-button
var btn = document.querySelectorAll(".modal-button");
// All page modals
var modals = document.querySelectorAll('.modal');
// Get the <span> element that closes the modal
var spans = document.getElementsByClassName("close");
// When the user clicks the button, open the modal
for (var i = 0; i < btn.length; i++) {
btn[i].onclick = function(e) {
e.preventDefault();
modal = document.querySelector(e.target.getAttribute("href"));
modal.style.display = "block";
open_modals.push(modal.id);
document.body.style.overflow = "hidden";
if (this.parentElement.nodeName == 'BODY') {
document.body.classList.add("open");
} else {
this.parentElement.parentElement.parentElement.classList.add("open");
}
}
}
function checkRenableScroll() {
if (!open_modals.length) {
document.body.style.overflow = "scroll";
}
}
// When the user clicks on <span> (x), close the modal
for (var i = 0; i < spans.length; i++) {
spans[i].onclick = function() {
for (var index in modals) {
if (typeof modals[index].style !== 'undefined' && modals[index].id == open_modals[open_modals.length - 1]) {
modals[index].classList.add("modal-content-active");
var item = modals[index];
if (index > 0) {
spans[index - 1].parentElement.parentElement.classList.remove("open");
} else {
document.body.classList.remove("open");
}
setTimeout(function() {
item.classList.remove("modal-content-active");
item.style.display = "none";
open_modals.pop();
checkRenableScroll();
}, 400);
}
}
}
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
for (var index in modals) {
if (typeof modals[index].style !== 'undefined' && modals[index].id == open_modals[open_modals.length - 1]) {
modals[index].classList.add("modal-content-active");
var item = modals[index];
if (index > 0) {
spans[index - 1].parentElement.parentElement.classList.remove("open");
} else {
document.body.classList.remove("open");
}
setTimeout(function() {
item.classList.remove("modal-content-active");
item.style.display = "none";
open_modals.pop();
checkRenableScroll();
}, 400);
}
}
}
}
})
CSS
@import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
/* The Modal (background) */
.modal {
box-sizing: border-box;
font-family: 'Quicksand', sans-serif;
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 3.125rem;
/* 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 {
color: white;
position: relative;
background-color: #171B20;
margin: auto;
padding: 0;
border: 0.0625rem solid #888;
width: 90%;
box-shadow: 0 0.25rem 0.5rem 0 rgba(0, 0, 0, 0.2), 0 0.375rem 1.25rem 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;
}
}
@-webkit-keyframes animateBottom {
from {
top: 0px;
opacity: 1;
}
to {
top: 500px;
opacity: 0;
}
}
@keyframes animateBottom {
from {
top: 0px;
opacity: 1;
}
to {
top: 300px;
opacity: 0;
}
}
.modal-content-active {
-webkit-animation-name: animateBottom;
-webkit-animation-duration: 0.4s;
animation-name: animateBottom;
animation-duration: 0.4s;
}
/* The Close Button */
.close {
color: #F0B823;
float: right;
font-size: 2.6rem;
font-weight: bold;
position: absolute;
right: 0.25rem;
top: -0.25rem;
}
.close:hover,
.close:focus {
color: #fff;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 0.125rem 1rem;
background-color: #171B20;
color: #F0B823;
}
.modal-body {}
.modal-button {
font-family: 'Quicksand', sans-serif;
background-color: #171B20;
border: none;
color: white;
padding: 0.248em 0.496em;
text-align: left;
text-decoration: none;
display: inline-block;
font-size: 1.750rem;
margin: 0.124em 0.062em;
-webkit-transition-duration: 0;
/* Safari */
transition-duration: 0;
cursor: pointer;
width: auto;
}
.modal-button:hover {
background-color: #171B20;
color: #F0B823;
}
.pic {
margin: auto;
display: block;
height: auto;
width: 50vh;
}
.headertext {
font-family: 'Quicksand', sans-serif;
display: block;
text-align: center;
font-size: 2rem;
}
.bodytext {
font-size: 1.125rem;
font-family: 'Quicksand', sans-serif;
display: block;
padding: 0.625em 0.9375em;
line-height: 2rem;
}
p {
display: block;
margin: 0;
padding: 0;
}
.open > *{
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
}
.modal {
-webkit-filter: blur(0px);
-moz-filter: blur(0px);
-o-filter: blur(0px);
-ms-filter: blur(0px);
filter: blur(0px);
}
.modal .open{
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
工作的 HTML 代码
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Trigger/Open The Modal -->
<a href="#myModal1" class="modal-button">• Click Me</a>
<!-- The Modal -->
<div id="myModal1" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Header
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Your are viewing first modal<br>
<a href="#myModal2" class="modal-button">Click Here to Open Second Modal</a>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal2" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Header
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Your are currently viewing second modal
</div>
</div>
</div>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque arcu est, lacinia ut posuere ut, lacinia quis ipsum. Quisque eleifend quam velit, nec accumsan ligula maximus eget. Praesent diam lorem, auctor quis justo sit amet, pretium molestie odio. Proin at est sed augue vestibulum malesuada at non lorem. Donec sit amet nisi dapibus, venenatis enim id, tristique enim. Maecenas vel sagittis arcu. Praesent et cursus tellus. Donec rhoncus blandit arcu, eu rhoncus dui semper vel. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque eu nulla luctus, consectetur leo id, ornare urna.
Integer id molestie libero, in pulvinar diam. Donec non massa metus. Integer ut velit nec turpis fermentum iaculis et sagittis dui. Vestibulum vel dignissim lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec ac luctus lacus, ac ultrices arcu. Curabitur dignissim arcu mauris, et eleifend lacus imperdiet nec.
Nullam eleifend massa metus, vitae sagittis erat egestas vel. Maecenas fringilla, risus ut maximus mattis, nibh lacus maximus quam, at elementum erat lectus ac urna. Aenean egestas eleifend neque, et egestas justo condimentum a. Fusce in dapibus ligula. Aliquam dui felis, vestibulum quis est a, facilisis auctor est. Vestibulum ac elit eu mauris gravida aliquam sed ut orci. Ut tincidunt lacus non gravida pharetra.
</p>
现在尝试用 this 替换上面的 html 代码模糊功能的行为非常奇怪
希望有人能找出这个问题的原因
带有工作 html 代码的 JSBIN here
带有非工作 html 代码的 JSBIN here
注意JavaScript和css代码是完全一样的,唯一不同的是html
最佳答案
您的代码将模糊效果应用于类为 .open
的元素的所有直接子元素。 (.open > *
)。
然而,.modal
有一个特殊规则,会将其重置为 blur(0px)
, 覆盖 .open > *
规则。
要让它工作,你必须有这个 .modal
元素是将接收 .open
的元素的直接子元素类(class)。这是您在第一个片段中拥有的内容,但在第二个片段中却没有。
由于在第二个中它不是该元素的直接子元素,因此 .modal
的 parent 将收到过滤器。此时,将其从您的 .modal
中删除已经为时已晚。元素。
.open > * {
filter: blur(5px);
}
.modal {
filter: none;
}
<div class="open">
<div>
A direct Child, not .modal (and thus blurred).
<p> Some inner content, still not .modal </p>
</div>
<div>
A direct Child, not .modal (and thus blurred).
<p class="modal"> Some inner content. This time .modal but blurred by its parent anyway...</p>
</div>
<div class="modal">
A direct Child, .modal (and thus not blurred).
<p class="modal"> Some inner content. not blurred either</p>
</div>
</div>
因此您必须将此文档结构保留在您的 .modal
所在的位置元素将是 .open
的直接子元素元素并设置 .open
在一个共同的父级上上课(例如 <body>
)。要应用的另一项更改位于 this.parentElement.nodeName == 'BODY'
行自 this
是<a>
还有这个<a>
现在是 <section>
的 child ,您需要将其更改为 this.parentElement.nodeName == 'SECTION'
或 this.parentElement.nodeName == 'BODY'
:
let open_modals = [];
$(function() {
// Get the button that opens the modal
// read all the control of any type which has class as modal-button
var btn = document.querySelectorAll(".modal-button");
// All page modals
var modals = document.querySelectorAll('.modal');
// Get the <span> element that closes the modal
var spans = document.getElementsByClassName("close");
// When the user clicks the button, open the modal
for (var i = 0; i < btn.length; i++) {
btn[i].onclick = function(e) {
e.preventDefault();
modal = document.querySelector(e.target.getAttribute("href"));
modal.style.display = "block";
open_modals.push(modal.id);
document.body.style.overflow = "hidden";
if (this.parentElement.parentElement.nodeName == 'BODY') {
document.body.classList.add("open");
} else {
this.parentElement.parentElement.parentElement.classList.add("open");
}
}
}
function checkRenableScroll() {
if (!open_modals.length) {
document.body.style.overflow = "scroll";
}
}
// When the user clicks on <span> (x), close the modal
for (var i = 0; i < spans.length; i++) {
spans[i].onclick = function() {
for (var index in modals) {
if (typeof modals[index].style !== 'undefined' && modals[index].id == open_modals[open_modals.length - 1]) {
modals[index].classList.add("modal-content-active");
var item = modals[index];
if (index > 0) {
spans[index - 1].closest('.open').classList.remove("open");
} else {
document.body.classList.remove("open");
}
setTimeout(function() {
item.classList.remove("modal-content-active");
item.style.display = "none";
open_modals.pop();
checkRenableScroll();
}, 400);
}
}
}
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
for (var index in modals) {
if (typeof modals[index].style !== 'undefined' && modals[index].id == open_modals[open_modals.length - 1]) {
modals[index].classList.add("modal-content-active");
var item = modals[index];
if (index > 0) {
spans[index - 1].closest('.open').classList.remove("open");
} else {
document.body.classList.remove("open");
}
setTimeout(function() {
item.classList.remove("modal-content-active");
item.style.display = "none";
open_modals.pop();
checkRenableScroll();
}, 400);
}
}
}
}
})
@import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
/* The Modal (background) */
.modal {
box-sizing: border-box;
font-family: 'Quicksand', sans-serif;
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 3.125rem;
/* 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 {
color: white;
position: relative;
background-color: #171B20;
margin: auto;
padding: 0;
border: 0.0625rem solid #888;
width: 90%;
box-shadow: 0 0.25rem 0.5rem 0 rgba(0, 0, 0, 0.2), 0 0.375rem 1.25rem 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;
}
}
@-webkit-keyframes animateBottom {
from {
top: 0px;
opacity: 1;
}
to {
top: 500px;
opacity: 0;
}
}
@keyframes animateBottom {
from {
top: 0px;
opacity: 1;
}
to {
top: 300px;
opacity: 0;
}
}
.modal-content-active {
-webkit-animation-name: animateBottom;
-webkit-animation-duration: 0.4s;
animation-name: animateBottom;
animation-duration: 0.4s;
}
/* The Close Button */
.close {
color: #F0B823;
float: right;
font-size: 2.6rem;
font-weight: bold;
position: absolute;
right: 0.25rem;
top: -0.25rem;
}
.close:hover,
.close:focus {
color: #fff;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 0.125rem 1rem;
background-color: #171B20;
color: #F0B823;
}
.modal-body {}
.modal-button {
font-family: 'Quicksand', sans-serif;
background-color: #171B20;
border: none;
color: white;
padding: 0.248em 0.496em;
text-align: left;
text-decoration: none;
display: inline-block;
font-size: 1.750rem;
margin: 0.124em 0.062em;
-webkit-transition-duration: 0;
/* Safari */
transition-duration: 0;
cursor: pointer;
width: auto;
}
.modal-button:hover {
background-color: #171B20;
color: #F0B823;
}
.pic {
margin: auto;
display: block;
height: auto;
width: 50vh;
}
.headertext {
font-family: 'Quicksand', sans-serif;
display: block;
text-align: center;
font-size: 2rem;
}
.bodytext {
font-size: 1.125rem;
font-family: 'Quicksand', sans-serif;
display: block;
padding: 0.625em 0.9375em;
line-height: 2rem;
}
p {
display: block;
margin: 0;
padding: 0;
}
.open>* {
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
}
.modal {
-webkit-filter: blur(0px);
-moz-filter: blur(0px);
-o-filter: blur(0px);
-ms-filter: blur(0px);
filter: blur(0px);
}
.modal .open {
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section id="home">
<span class="header2 etpadding">Welcome To</span><br>
<br><span class="header1 tpadding">WTS<br>SHOP</span><br>
<span class="header2 mtpadding">This is a test for checking background blur</span><br>
<a href="#product" class="button" data-scroll>Check out our Product catalogue</a><br>
</section>
<section id="product">
<span class="header3">This is a test</span><br>
<!-- Trigger/Open The Modal -->
<a href="#myModal1" class="modal-button">• Modal Button 1</a>
<p>Modal Window 2 to be launched through body of Modal 1</p>
<!-- Trigger/Open The Modal -->
<a href="#myModal3" class="modal-button buttonalign">• Modal button 3</a><br>
<!-- Trigger/Open The Modal -->
<a href="#myModal4" class="modal-button buttonalign">• Modal Button 4</a><br>
</section>
<section id="payment">
<span class="header3">Supported Payment Methods</span>
</section>
<section id="disclaimer">
<span class="header3">Disclaimer</span>
</section>
<section id="contact">
<span class="header3">Contact Us</span>
</section>
<!-- The Modals must be direct children of <body> -->
<!-- The Modal -->
<div id="myModal1" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 1
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
currently viewing modal no.1
<a href="#myModal2" class="modal-button">Click to open modal window no.2</a>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal2" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 2
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
You are currently viewing modal no.2
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal3" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 3
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Currently viewing modal window 3
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal4" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 4
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Currently viewing modal window 4
</div>
</div>
</div>
</div>
请注意,我还更改了一些乱七八糟的 .parentElement.parentElement.etc.
使用更简单的 .closest(".open")
.
但是如果我可以为您提供一个完整的重写,因为您已经在使用 jQuery,现在就开始吧:
$(document)
.on('click', '.modal-button', openmodal)
.on('click', '.modal .close', closemodal)
.on('click', '.modal', closelastmodal);
function openmodal(evt) {
$(evt.target.getAttribute('href'))
.addClass('visible')
.parent().addClass('open');
}
function closemodal(evt) {
$(evt.target)
.closest('.modal.visible')
.removeClass('visible')
.parent()
.removeClass('open')
}
function closelastmodal(evt) {
if ($(evt.target).is('.modal')) {
closemodal(evt);
evt.stopImmediatePropagation();
}
}
@import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
/* The Modal (background) */
.open>* {
filter: blur(5px);
}
.modal .open {
filter: blur(5px);
}
.modal {
box-sizing: border-box;
font-family: 'Quicksand', sans-serif;
display: none;
position: fixed;
z-index: 1;
padding-top: 3.125rem;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
filter: none;
/* no blur for me */
}
.modal.visible {
display: block;
}
/* Modal Content */
.modal-content {
color: white;
position: relative;
background-color: #171B20;
margin: auto;
padding: 0;
border: 0.0625rem solid #888;
width: 90%;
box-shadow: 0 0.25rem 0.5rem 0 rgba(0, 0, 0, 0.2), 0 0.375rem 1.25rem 0 rgba(0, 0, 0, 0.19);
animation-name: animatetop;
animation-duration: 0.4s;
}
/* Add Animation */
@keyframes animatetop {
from {
top: -300px;
opacity: 0;
}
to {
top: 0;
opacity: 1;
}
}
@keyframes animateBottom {
from {
top: 0px;
opacity: 1;
}
to {
top: 300px;
opacity: 0;
}
}
.modal-content-active {
animation-name: animateBottom;
animation-duration: 0.4s;
}
/* The Close Button */
.close {
color: #F0B823;
float: right;
font-size: 2.6rem;
font-weight: bold;
position: absolute;
right: 0.25rem;
top: -0.25rem;
}
.close:hover,
.close:focus {
color: #fff;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 0.125rem 1rem;
background-color: #171B20;
color: #F0B823;
}
.modal-body {}
.modal-button {
font-family: 'Quicksand', sans-serif;
background-color: #171B20;
border: none;
color: white;
padding: 0.248em 0.496em;
text-align: left;
text-decoration: none;
display: inline-block;
font-size: 1.750rem;
margin: 0.124em 0.062em;
transition-duration: 0;
cursor: pointer;
width: auto;
}
.modal-button:hover {
background-color: #171B20;
color: #F0B823;
}
.pic {
margin: auto;
display: block;
height: auto;
width: 50vh;
}
.headertext {
font-family: 'Quicksand', sans-serif;
display: block;
text-align: center;
font-size: 2rem;
}
.bodytext {
font-size: 1.125rem;
font-family: 'Quicksand', sans-serif;
display: block;
padding: 0.625em 0.9375em;
line-height: 2rem;
}
p {
display: block;
margin: 0;
padding: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section id="home">
<span class="header2 etpadding">Welcome To</span><br>
<br><span class="header1 tpadding">WTS<br>SHOP</span><br>
<span class="header2 mtpadding">This is a test for checking background blur</span><br>
<a href="#product" class="button" data-scroll>Check out our Product catalogue</a><br>
</section>
<section id="product">
<span class="header3">This is a test</span><br>
<!-- Trigger/Open The Modal -->
<a href="#myModal1" class="modal-button">• Modal Button 1</a>
<p>Modal Window 2 to be launched through body of Modal 1</p>
<!-- Trigger/Open The Modal -->
<a href="#myModal3" class="modal-button buttonalign">• Modal button 3</a><br>
<!-- Trigger/Open The Modal -->
<a href="#myModal4" class="modal-button buttonalign">• Modal Button 4</a><br>
</section>
<section id="payment">
<span class="header3">Supported Payment Methods</span>
</section>
<section id="disclaimer">
<span class="header3">Disclaimer</span>
</section>
<section id="contact">
<span class="header3">Contact Us</span>
</section>
<!-- The Modals must be direct children of <body> -->
<!-- The Modal -->
<div id="myModal1" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 1
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
currently viewing modal no.1
<a href="#myModal2" class="modal-button">Click to open modal window no.2</a>
</div>
</div>
</div>
<div id="myModal2" class="modal">
<!-- Move inner modal inside as a direct child of the first modal -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 2
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
You are currently viewing modal no.2
</div>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal3" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 3
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Currently viewing modal window 3
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div id="myModal4" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<div class="headertext">
Modal Window 4
</div>
</div>
<div class="modal-body">
<img class="pic" src="https://drive.google.com/thumbnail?id=108ZLeoIfNkKODfRbLuPWpmXRl0gH9qkD">
<div class="bodytext">
Currently viewing modal window 4
</div>
</div>
</div>
</div>
关于javascript - body 背景模糊功能普遍无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57798103/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!