码迷,mamicode.com
首页 > 其他好文 > 详细

背景图100%出现滚动条时会有空白bug

时间:2017-06-28 13:08:42      阅读:387      评论:0      收藏:0      [点我收藏+]

标签:背景   元素   nbsp   win   width   技术分享   ges   size   out   

技术分享

 

.loginWrap { position:absolute;top: 0;left: 0;width:100%;height: 100%;}

window.onresize = function(){
var widthOfMobile = $(‘#warpBackground‘). outerHeight();
var withoutMargin = $(‘#mobileWarp‘). outerHeight();
$(‘#mobileBg‘).css(‘height‘,widthOfMobile);
$(‘#bg‘).css(‘height‘,withoutMargin);
}

动态控制bg的高度 使其始终等于html 这样就不会出现空白区域,
outerHeight()元素距离顶端的高度 (加上滚动条的距离)

背景图100%出现滚动条时会有空白bug

标签:背景   元素   nbsp   win   width   技术分享   ges   size   out   

原文地址:http://www.cnblogs.com/mamimi/p/7089013.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!