jquery - Opera 以一种非常奇怪的方式处理 jQuery 的 animate 方法

标签 jquery animation opera

我有一个下拉菜单。它的高度通过 jQuery 从 5px 到 130px 进行动画处理,反之亦然。

菜单在分离元素时工作正常(当我开发它时),但是 当另一个元素出现时 Opera 却出人意料:

alt text http://img12.imageshack.us/img12/9366/menusy.png

我将第一个状态标记为 1,将第二个状态标记为 2。第三个状态应该与第一个状态相同,但正如您所看到的,它有一个“尾部”。

UPD:源代码

html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <script type="text/javascript" src="js/jquery.js">
    </script>
    <script type="text/javascript" src="js/script.js">
    </script>
    <script type="text/javascript">
      $(function(){
        init();
      });
    </script>
    <link rel="stylesheet" href="css/styles.css"/>
</head>
<body>
  <div id="side" class="side_outer"> 
        <div class="cn tr"> </div>
        <div class="cn tl"> </div>

        <div class="auth">
          <span class="auth_entr">Click me</span> 
          <div class="auth_fields"> 

          </div>
          <div id="auth_separator"> </div>
        </div>
        <div class="side_inner">
            <div class="cn tr"> </div>
            <div class="cn tl"> </div>
                <div class="side_content">
                    Some content
                </div>   
            <div class="cn br"> </div>
            <div class="cn bl"> </div>
        </div>
        <div class="cn br"> </div>
        <div class="cn bl"> </div>  
  </div>
  <div id="header"> Header</div>
  <div id="central"> Center</div>
</body>
</html>

CSS:

#header {
  background: red;
  height: 100px;
  margin: 30px 330px 20px 20px;

}

#central {
  background: green;
  height: 150px;
  margin: 20px 330px 20px 20px;
}

#side {
  margin-right: 3%;
  margin-left: 10px;
  margin-top: 30px;
  min-width: 200px;
  float: right;
}

.side_outer {
  padding: 0 10px;
  background: #f2f2cc;
  width: 22%;
  border-bottom-style: dashed;
  border-bottom-width: 2px;
  border-bottom-color: black;
}

.side_inner {
    position:relative;
    overflow:hidden;
    padding: 0 10px;
    background: #accbfa;  
}

.side_outer .cn {
  position: relative;
  width: 20px;
  height: 20px;
}

.side_outer .cn.tr, .side_outer .cn.br {
  float: right;
  left: 10px;
}

.side_outer .cn.tl, .side_outer .cn.bl {
  left: -10px;
}

.auth {
  overflow: hidden;
}

.auth_entr {
  position: relative;
  top: 5px;
  margin-left: 17px;
  padding:  0 5px;
  color:  #1e5ebe;
  cursor: pointer;
}

.auth_fields {
  overflow: hidden;
  height: 5px;
  margin-top: 5px;
}


#auth_separator {
  height: 6px;
  font-size: 2px;
}

.side_content {
  height: 100px;
  padding: 5px 15px;
}

JavaScript:

var auth_state = 1;

function init () {
  $('span.auth_entr').click (function (){
     auth_state = (auth_state + 1) % 2;
     if (auth_state == 1) {
          $('div.auth_fields').animate({height: '5px'},  1000);
     } else {
          $('div.auth_fields').animate({height: '132px'}, 1000);
     }
  });
}

实际上,我已经使用一些街头魔法解决了这个问题(我在菜单底部添加了粗的白色边框,现在“故事”是透明的)。但我很好奇问题是什么,有什么正常的解决方案吗?

附注另一个元素实际上是具有固定尺寸和背景的空 div。我的 Opera 版本是 9.5(我知道它很旧,但在我的观众中仍然很受欢迎)。

P.P.S。我刚刚在 Opera 9.6 中测试过,也出现了同样的错误。

最佳答案

我在 IE 7、8 和 FF3 下测试了你的代码,它工作正常。然而,正如您已经指出的,在 Opera 中运行动画时确实存在一个错误。我在 Opera 9.64 中测试了它,得到了和你一样的结果。

我在 Google 和 Opera 论坛中进行了搜索,但找不到任何对此特定错误的引用。我能找到的最接近的是: jquery-smooth-scroll-bugs

您可能需要创建一个票证来向 Opera 报告此错误。

关于jquery - Opera 以一种非常奇怪的方式处理 jQuery 的 animate 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/846334/

相关文章:

javascript - 无法加载资源: the server responded with a status of 405 (Method Not Allowed)

asp.net-mvc - asp.net mvc禁用ajax缓存

CSS 问题 - 链接(位置 :absolute) above a Box not work in IE + Opera

javascript - 如何从 "for..in"循环中的处理中排除添加到数组的方法? (javascript)

javascript - Jquery 文本字段最多 3 次验证

javascript - Bootstrap 可搜索下拉菜单

javascript - setInterval 循环动画不起作用

CSS 从左到右移动文本

ios - 在 ARKit 中为 SCNText 设置动画

jquery - 为什么 Opera 9.6 不能在我的代码中使用 Jquery 上下文选择器