jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 在Div内部滚动时将DIV定位为固定时闪烁大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有4个DIV,我正在改变滚动的4个元素的位置,如下所示

function adjustPositions(E) {
    var div = e ? $(this) : $('.parent');
    div.find('.left').css({
      left: div.scrollLeft() + "px"
    });
    var right = div.find('.right');
    right.css({
       left: div.scrollLeft() + div.width() - right.width() + "px"
    });
    div.find('.header').css({
       top: div.scrollTop() + "px"
    });
    var bottom = div.find('.footer');
    bottom.css({
      top: div.scrollTop() + div.height() - bottom.height() + "px"
    });
 }
 adjustPositions();
 $('.parent').on('scroll',adjustPositions);

这是小提琴http://jsfiddle.net/8NL2S/5/,当我在Safari中测试它时,它闪烁.没什么好看的. Safari多次在同样的情况下踢了我的希望.我怎样才能解决这个问题.

解决方法@H_197_13@
如果您的div大小是固定的,并且您希望在所有浏览器中处于相同位置,则无需调用js函数,只需设置css float:left;具有所有div的属性,并在该4 div的外部div上使用cf class.例如:

HTML:

<div class="parent">
    <div class="static cf">
        <div class="left"></div>
        <div class="right"></div>
        <div class="header"></div>
        <div class="footer"></div>
    </div>
</div>

CSS:


.header{
    border:1px solid red;
    width:100px;
    height:100px;
    BACkground-color:#F2F2F2;
    float:left;
    top:0px;
    left:0px;
    z-index:10;
}
.left{
    border:1px solid red;
    height:100px;
    width:100px;
    left:0px;
    float:left;
    top:100px;
    BACkground-color:#CCc;
}
.right{
    border:1px solid red;
    height:100px;
    width:100px;
    right:0px;
    float:left;
    top:100px;
    BACkground-color:#CCc;
}
.footer{
    border:1px solid red;
    width:100px;
    height:100px;
    BACkground-color:#F2F2F2;
    float:left;
    left:0px;
    bottom:0px;
    z-index:10;
}
.static{
    height:105px;
    width:410px;
    position:relative;
}
.cf{Clear:both}

大佬总结

以上是大佬教程为你收集整理的jquery – 在Div内部滚动时将DIV定位为固定时闪烁全部内容,希望文章能够帮你解决jquery – 在Div内部滚动时将DIV定位为固定时闪烁所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。