我有以下代码:
if ($('body.page-service-map').length || $('body.page-contact').length) {
$(document.body).append('<div class="black-overlay"></div>');
}
$('body.page-service-map img, body.page-contact img').on('click', function () {
var c = $(this).clone();
c.addClass('service-map-expanded');
$(document.body).append('<div class="service-map-container"></div>');
$('.service-map-container').append('<div class="service-map-close"></div>', c);
$('.black-overlay').show();
});
$('.service-map-close').on('mouseover', function () {
$('.service-map-container').remove();
$('.black-overlay').hide();
});
这是一个自定义图像弹出窗口。试图为它实现关闭按钮。看到关闭按钮,但鼠标事件不会触发它。虽然按钮对 css 悬停效果做出正确反应。这是CSS:
.service-map-container {
position: fixed;
top: 50%;
left: 50%;
margin-left: -500px;
margin-top: -300px;
width: 1000px;
z-index: 9990;
}
.service-map-close {
position: absolute;
top: -25px;
right: -25px;
width: 28px;
height: 28px;
background: url('../images/close.gif') no-repeat scroll 1px 1px #FFF;
z-index: auto;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 15px;
cursor: pointer;
}
.service-map-close:hover {
background-position: -25px 1px;
}
.service-map-expanded {
width: 1000px;
z-index: auto;
}
.black-overlay {
position: fixed;
top: 0;
left: 0;
z-index: 8888;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
display: none;
}