gpt4 book ai didi

javascript - scrollToFixed - 奇怪的滚动问题

转载 作者:可可西里 更新时间:2023-11-01 13:12:59 29 4
gpt4 key购买 nike

我正在尝试使用 ScrollToFixed 进行简单的固定滚动, 但我遇到了一些奇怪的行为

我准备了一个jsfiddle显示出以下问题:

html:

<div class="row-fluid">
<div id="car_left_col" class="span2">left</div>
<div id="car_center" class="span8">
<div class="car_main thumbnail">
<div class="car_cover">
<img alt="" src="http://www.autopulze.com/wp-content/uploads/2012/07/Rolls-Royce-Silver-Ghost-the-Best-Car-in-the-World.jpg">
</div>
<hr>
<div class="car_page_creator"></div>
</div>
<div class="car_talk">here are the comments for the car</div>
</div>
<div id="car_right_col" class="span2">
<div class="car_vote test_fixed">I should not move</div>
</div>
<div class="long"></div>

CSS:

.long {
height: 10000px;
}
#car_right_col {
position: relative;
}
.car_main {
position: relative;
padding: 0;
}
.car_cover {
width: 100%;
position: relative;
}
.car_cover img {
width: 100%;
}
.test_fixed {
position: static;
}
.car_vote {
position: relative;
}

js:

$(document).ready(function () {
$('.test_fixed').scrollToFixed({
marginTop: 45,
limit: $('.car_page_creator').offset().top
});

});
  1. 当一直向下滚动时,请注意水平滚动条,将页面向右可笑地拉伸(stretch)
  2. 我认为这与第一个问题有关,要修复的元素 .test-fixed 在向下滚动时具有非常大的 left 属性<
  3. 通过单击并按住滚动条向上(从一直向下)滚动时,一旦到达固定元素的点,它就会不稳定

我认为我的 html 和 css 非常标准,没有什么特别之处。这种行为是由于我的代码还是插件中的错误造成的?

最佳答案

我已经为你更新了你的 fiddle :

http://jsfiddle.net/kspA8/17/embedded/result/

.test_fixed {
position: static;
left: auto !important;
}

将 auto left 属性应用于您的上下文元素似乎已经修复了它:)

关于javascript - scrollToFixed - 奇怪的滚动问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16898629/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com