【发布时间】:2017-04-03 03:54:31
【问题描述】:
我正在开发一个网页,用户可以在其中通过悬停显示每个缩略图的大图或预览。
我正在使用此 Jquery 代码响应式地在屏幕上显示和居中较大的图像。
var timer;
$(".theme-preview").hover(function() {
var self = $(this);
timer = setTimeout(function() {
timer = false;
$(self).children('.popup-preview').fadeIn("slow");
$(self).children('.popup-preview').css("position", "fixed");
$(self).children('.popup-preview').css("top", ($(window).height() / 2) - ($(self).children('.popup-preview').outerHeight() / 2));
$(self).children('.popup-preview').css("left", ($(window).width() / 2) - ($(self).children('.popup-preview').outerWidth() / 2));
}, 800);
//return false;
},
function() {
if (timer) {
clearTimeout(timer);
timer = false;
} else {
$(this).children('.popup-preview').fadeOut("fast");
}
//return false;
}
);
如何将较大的图像与父类垂直对齐?
Here is my working sample code.
更新:示例是缩略图位于屏幕顶部或底部并悬停时。较大的图像应显示在屏幕的垂直中心。
【问题讨论】:
标签: javascript jquery html css