我需要一些帮助来弄清楚如何使锚链接正常工作以及随后关闭弹出窗口。 当前,弹出窗口有效,但是在单击锚链接后仍保持打开状态。这是针对WordPress中的一页布局。
HTML
<div class="popup1" data-popup="popup-1">
<div class="cnt223">
<a data-popup-close="popup-1" href="#" class="close"><i class="fa fa-times" aria-hidden="true"></i>
</a>
<h2>Re-Opening Soon!!!</h2>
<h2><a style="font-size:22px;color:#bc2a3a;" href="/#facility">Click Here to See Our New Facility</a></h2>
</div>
<div class="close-layer" data-popup-close="popup-1">
</div>
</div>
CSS
<style>
.popup1 {
width:100%;
height:100%;
position:fixed;
top:0px;
left:0px;
z-index:999999;
}
.close-layer{top:0px;
left:0px;
background:rgba(0,0,0,0.30);width:100%;
height:100%; position: absolute;
z-index: 999;}
.cnt223 {
z-index: 9999;
}
/* Inner */
.popup-inner {
max-width:700px;
width:90%;
padding:40px;
position:absolute;
top:50%;
left:50%;
-webkit-transform:translate(-50%, -50%);
transform:translate(-50%, -50%);
box-shadow:0px 2px 6px rgba(0,0,0,1);
border-radius:3px;
background:#fff;
}
/* Close Button */
.popup-close {
width:30px;
height:30px;
padding-top:4px;
display:inline-block;
position:absolute;
top:0px;
right:0px;
transition:ease 0.25s all;
-webkit-transform:translate(50%, -50%);
transform:translate(50%, -50%);
border-radius:1000px;
background:rgba(0,0,0,0.8);
font-family:Arial, Sans-Serif;
font-size:20px;
text-align:center;
line-height:100%;
color:#fff;
}
.popup-close:hover {
-webkit-transform:translate(50%, -50%) rotate(180deg);
transform:translate(50%, -50%) rotate(180deg);
background:rgba(0,0,0,1);
text-decoration:none;
}
.popup-1 {animation: popup 1 3s ease-in-out;}
@keyframes popup {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
0% {
opacity: 0;
visibility: hidden;
}
100% {
opacity: 1;
visibility: visible;
}
}
</style>
JavaScript
<script type='text/javascript'>
jQuery(function() {
//----- OPEN
jQuery('[data-popup-open]').on('click', function(e) {
var targeted_popup_class = jQuery(this).attr('data-popup-open');
jQuery('[data-popup="' + targeted_popup_class + '"]').fadeIn(350);
e.preventDefault();
});
//----- CLOSE
jQuery('[data-popup-close]').on('click', function(e) {
var targeted_popup_class = jQuery(this).attr('data-popup-close');
jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
e.preventDefault();
});
//----- CLOSE
jQuery('[data-popup-close2]').on('mouseup', function(e) {
var targeted_popup_class = jQuery(this).attr('data-popup-close');
jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
e.preventDefault();
});
});
</script>