不同分辨率手机上使盒子适中居中显示
文章目录
具体代码如下:
//可能会产生闪烁问题,所以首先将盒子隐藏
$(function () {
elementCenter();
$(window).resize(function () {
elementCenter();
})
function elementCenter() {
$('.box').click(function () {
var height = $(window).height() - $('.box').height()
$(this).offset({
top: height / 2,
}).css({
display: 'block'
})
})
$('.box').trigger("click")
}
})

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论