我有一些javascript,它将一个固定的类应用到我的侧边栏中,所以当您滚动时,菜单将保留在您的身边。Stackoverflow有类似的问题侧边栏。
$(function() {
var top = $('.side-menu').offset().top - parseFloat($('.side-menu').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('.side-menu').addClass('fixed');
$('body').addClass('fixed-sidebar');
} else {
// otherwise remove it
$('.side-menu').removeClass('fixed');
$('body').removeClass('fixed-sidebar');
}
});
});在我的CSS中,我有* { box-sizing: border-box; },它会导致其他的触发和页面跳转。当我移除盒子大小时,固定菜单可以按需要工作。
我的问题是
box-sizing属性吗?编辑
使用此链接进行演示:在不同的高度调整浏览器窗口的大小,您将看到问题所在。http://dev.danielcgold.com/fixed-menu.html
发布于 2012-08-16 16:25:42
当然,您总是可以做(selector) { box-sizing: content-box }。(这将“取消”您的box-sizing.)
https://stackoverflow.com/questions/11991556
复制相似问题