gpt4 book ai didi

javascript - body 背景模糊功能普遍无法正常工作

转载 作者:行者123 更新时间:2023-11-28 00:33:02 25 4
gpt4 key购买 nike

我创建了一个模态,其中我在模态窗口打开时使 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com