简体   繁体   English

IE中带有水平滚动的顶部固定菜单

[英]Top fixed menu with horizontal scroll in IE

I've created top menu bar with horizontal scroll, the top property is being set via JS: 我用水平滚动创建了顶部菜单栏, top属性是通过JS设置的:

$(document).on('scroll', function() {
    $('#headers').css('top', $(this).scrollTop());
});

The problem is when I'm scrolling the page vertically in IE, menu bar is trying to scroll too and it doesn't look good. 问题是,当我在IE中垂直滚动页面时,菜单栏也试图滚动,但效果不好。 Any ideas to fix that? 有什么解决办法吗?

JSFiddle demo JSFiddle演示

does this give you the desired output? 这会给您所需的输出吗?

#headers {
  overflow: hidden;
}

Working Example: http://jsfiddle.net/khristopherallen/f15vybt7/ 工作示例: http : //jsfiddle.net/khristopherallen/f15vybt7/

If you change your #headers to a fixed position, then the jQuery should not be necessary. 如果将#headers更改为固定位置,则jQuery不必要。 You then just need to add some margin to the top of your page so the content doesn't start under the header. 然后,您只需要在页面顶部添加一些边距,这样内容就不会在标题下方开始。

#headers {
    background-color: #333;
    margin: 0px 0px 0px 0px;
    top: 0;
    left:0;
    width: 100%;
    z-index:600;
    position: fixed;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM