简体   繁体   English

Safari中的粘边栏滚动问题

[英]Sticky sidebar scrolling issue in Safari

I have a right sidebar that, when scrollled, has a "sticky" class added to it using jQuery. 我有一个右侧栏,当滚动时,使用jQuery向其添加了“粘性”类。 This works perfectly fine in Firefox and Chrome - however, in Safari, the sidebar gets pushed to the left and overlaps the main content. 在Firefox和Chrome浏览器中,这非常完美-但是,在Safari中,边栏被推到左侧并与主要内容重叠。 I'm sure this has to do with fixed positioning but I'm not sure of an answer to fix it. 我确定这与固定位置有关,但是我不确定是否有解决办法。

You can see an example of the issue here when you scroll: http://tsb.catalystdigitalpartners.com/real-tennis-and-lawn-tennis-a-conversation-starter/ 滚动时,您可以在此处看到问题的示例: http : //tsb.catalystdigitalpartners.com/real-tennis-and-lawn-tennis-a-conversation-starter/

I have the following pertinent code: 我有以下相关代码:

CSS CSS

.widgets-sticky{
    position: fixed !important;
    top: 60px !important;   
}

Javascript Java脚本

if (windowPos > 60){
    $('#widgets-default').addClass('widgets-sticky');   
} else {
    $('#widgets-default').removeClass('widgets-sticky');    
};

As explained here: Why does Safari seem to have a problem with css position:fixed? 如此处所述: 为何Safari似乎在css position:fixed中有问题?

you need to give your sidebar a left/right position value when using position fixed. 使用固定位置时,您需要为边栏提供左/右位置值。 without a horizontal position value the browser doesnt know where to place the sidebar and so just has to guess. 如果没有水平位置值,浏览器将不知道将侧边栏放置在何处,因此只能猜测。

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

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