我使用 gsap.js 作为弹出窗口/模式。我使用 forEach,这样无论我添加这个网站有多少相同的部分,它都会正常工作。我唯一的目标是现在,以某种方式完美地完成这个工作。每当您单击弹出的“按钮”时,我就会出现,然后您会得到 9 个图像,并从中选择 4 个图像,然后单击“保存编辑”,当您按“保存编辑”然后是正文图像时,其中有 4 个图像身体,它会自动改变。并且您可以一次又一次地更改它。
const items = document.querySelectorAll(".mdlsc");
const modal = document.querySelector(".modal");
items.forEach((item, index) => {
item.querySelector(".opnBtn").addEventListener("click", () => {
item.querySelector(".modal").style.display = "grid";
gsap.to(item.querySelector(".modalwrap"), {
scale: 1,
ease: "elastic.out(1, 0.3)",
});
});
item.querySelector(".ovlybg").addEventListener("click", () => {
gsap.to(item.querySelector(".modalwrap"), {
scale: 0,
ease: "elastic.out(1, 0.3)",
});
item.querySelector(".modal").style.display = "none";
});
});
body {
width: 100%;
overflow-x: hidden;
color: #fff;
background: url(https://polite-figolla-02d41d.netlify.app/img/wefdf.png) no-repeat;
background-size: cover;
background-position: center center;
height: 100vh;
}
body img {
width: 100%;
}
body button {
background: transparent;
border: none;
cursor: pointer;
}
.main {
width: 500px;
margin: auto;
}
.modal {
position: fixed;
z-index: 9;
left: 0%;
top: 0%;
width: 100%;
height: 100vh;
place-content: center;
place-items: center;
display: none;
}
.modal .ovlybg {
position: absolute;
background: rgba(0, 0, 0, 0.5);
top: 0px;
left: 0%;
z-index: 1;
width: 100%;
height: 100%;
}
.modal .modalwrap {
transform: scale(0);
width: 400px;
margin: auto;
height: -webkit-fit-content;
height: -moz-fit-content;
height: fit-content;
border: 5px solid #fff;
border-radius: 77px;
position: relative;
z-index: 3;
background: linear-gradient(to right, #400df0, #6203b3, #940599);
text-align: center;
text-transform: uppercase;
font-weight: 600;
padding: 45px 0px;
}
.edtchp {
text-align: center;
padding: 25px 0px 2px;
}
.edtchp span {
font-size: 1em;
margin: 0;
}
.edtchp h1 {
font-size: 2.2em;
color: #fff;
margin: 0;
transform: translate(0px, 0px);
}
.clsebtn img {
width: 120px;
}
.mdlsc {
margin-left: 10px;
}
.grypnk {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
padding: 18px 5px;
width: 80%;
margin: auto;
}
.grypnk img {
width: 100% !important;
}
.coinsc {
display: flex;
align-items: center;
width: 85%;
margin: auto;
gap: 8px;
justify-content: center;
margin: 10px auto;
}
.coinsc .imdwidth {
display: flex;
align-items: center;
}
.coinsc .imdwidth img {
width: 45px;
}
.coin {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
align-items: center;
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号