简体   繁体   English

jquery animate为IE中的div删除滚动

[英]jquery animate removes scroll in div for IE

Right now I'm getting this strange problem where when I use jQuery's animate() function on a <div> it removes the ability to scroll. 现在我遇到了这个奇怪的问题,当我在<div>上使用jQuery的animate()函数时,它会删除滚动的能力。 I'm adjusting the height with animate() . 我正在用animate()调整高度。 This problem only comes up with IE and works fine with Chrome and FF. 这个问题只出现在IE上,并且适用于Chrome和FF。

Below is my css class for my div 下面是我的div的css类

div.fullscroll{

  height: 65%;
  width: 75%;
  overflow-x: hidden;
  overflow-y: scroll;
  border-top: 1px solid #347235;
  border-bottom: 2px solid #347235;
  border-right: 2px solid #347235;
  border-left: 2px solid #347235;
  -moz-border-radius-topleft:     .1em;
  -moz-border-radius-topright:    .1em;
  -moz-border-radius-bottomright: .2em;
  -moz-border-radius-bottomleft:  .2em;
  border-top-left-radius: .1em;
  border-top-right-radius: .1em;
  border-bottom-right-radius: .2em;
  border-bottom-left-radius: .2em;
  background-color: #FFF;
  padding: 0px;
  margin: 0px auto;
  position:relative;
}

Here is my JS Jquery animate where <div id='main'> 这是我的JS Jquery动画,其中<div id='main'>

$('#main').animate({
            height: "40%"
          }
          ,"slow");

After the animate is finished the <div> tag no longer has the ability to scroll. 完成动画后, <div>标签不再具有滚动功能。 I'm completely stumped on this and was wondering if anybody had an idea. 我对此完全感到困惑,并且想知道是否有人有想法。

(Once again this only happens in IE) (再一次这只发生在IE中)

I'm guessing that this might be IE's problem with setting percentage heights ( ref ). 我猜这可能是IE设置百分比高度( ref )的问题。 Try changing the height to a pixel value and see it if works. 尝试将高度更改为像素值并查看是否有效。

Also, is #main and .fullscroll the same div? 另外, #main.fullscroll是同一个div吗?

I was able to fix this using a quick workaround. 我能够通过快速解决方法解决这个问题。 After the animation is finished I add the overflow property back to the element. 动画完成后,我将overflow属性添加回元素。

like 喜欢

$('#main').animate({
       height: "40%"
     },function(){
       $('#main').css('overflow-y','scroll');
     }
);

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

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