(function($) {
function resize() {
// 左侧高度
var leftHeight = $(window).height();
$(".left-content").css("height", leftHeight);
// 右侧宽度
var scrollWidth = getScrollbarWidth();
var leftWidth = parseInt($(".left-content").css("width"), 10);
var rightWidth = $(window).width() - leftWidth - scrollWidth;
$(".right-content").css("width", rightWidth);
}
function getScrollbarWidth() {
var oP = document.createElement('p'),
styles = {
width: '100px',
height: '100px',
overflowY: 'scroll'
},
i,
scrollbarWidth;
for (i in styles) oP.style[i] = styles[i];
document.body.appendChild(oP);
scrollbarWidth = oP.offsetWidth - oP.clientWidth;
oP.remove();
return scrollbarWidth;
}
window.onload = resize();
$(window).resize(resize);
})(jQuery)
自适应的导航条
最新推荐文章于 2024-07-12 21:28:45 发布