3

我有一个下拉菜单。它的高度用 jQuery 动画从 5px 到 130px,反之亦然。

菜单在分离元素时运行良好(当我开发它时)但是当另一个元素出现时,Opera 让我们大吃一惊:

替代文字 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);
     }
  });
}

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

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

PPS 我刚刚在 Opera 9.6 中对其进行了测试,并且出现了同样的错误。

4

2 回答 2

5

我在 IE 7、8 和 FF3 下测试了你的代码,它运行良好。但是,正如您已经指出的那样,在 Opera 中运行动画时确实存在错误。我在 Opera 9.64 中对其进行了测试,并得到了与您相同的结果。

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

您可能需要创建票证才能报告 Opera 的此错误。

于 2009-05-12T07:46:18.693 回答
0

您可以在 之后放置一个空 div <div class="cn bl">,并将其高度设置为 50px(或任何足够的值),并将其下边距设置为相同但为负值(即 -50px)。

于 2010-06-21T16:58:58.697 回答