1

我对 jQuery 和 Opera 有一个奇怪的问题。当我使用 slideToggle() 时,它在 Firefox、Chorme、Safari 甚至 IE 中运行良好且流畅,但在 Opera 中却没有。在 Opera 中,动作有点中断:首先它移动一点,然后停止,最后直接跳到结束。

这是我的代码:

$("#new").hover(function(){ $(".intro").slideToggle(300) })

和链接:

某事的名称 某事的介绍

最奇怪的问题是:当我添加另一个链接(与另一个相同,期望其他 id)时,Opera 会很好地加载两个介绍跨度。但是只有一个介绍跨度,它并不顺利。

该代码现在也在 jsFiddle 上(http://jsfiddle.net/3YstS/6)。

4

2 回答 2

0

评论中对 Blowsie的测试表明确实存在错误。奇怪的行为。您是否在Opera 错误向导上报告了它。

在这里发布好的代码,以便人们在 jsfiddle 消失时有参考。

JAVASCRIPT

$(".new").hover(function(){
    $(this).find('.intro').stop(true,true).slideToggle(300)
})

HTML 代码

    <div><a href="#" class="new">
    <span class="bottom">
        <span class="name">
            The name of something
        </span>
        <span class="intro" style="display: none;">
            The introduction of something
        </span>
    </span>
</a></div>
<div style="clear:both"><br/></div>
<div><a href="#" class="new">
    <span class="bottom">
        <span class="name">
            The name of something
        </span>
        <span class="intro" style="display: none;">
            The introduction of something
        </span>
    </span>
</a>
</div>
<div style="clear:both"><br/></div>
<div><a href="#" class="new">
    <span class="bottom">
        <span class="name">
            The name of something
        </span>
        <span class="intro" style="display: none;">
            The introduction of something
        </span>
    </span>
</a>
</div>
<div style="clear:both"><br/></div>
<div><a href="#" class="new">
    <span class="bottom">
        <span class="name">
            The name of something
        </span>
        <span class="intro" style="display: none;">
            The introduction of something
        </span>
    </span>
</a>
</div>
<div style="clear:both"><br/></div>

CSS 代码

.new {
    display: block;
    width: 594px;
    height: 100px;
    position: relative;
    border: 1px solid #000;
}

    .bottom {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
    }


    .name {
        font-size: 15px;
        font-weight: bold;
        padding: 6px;
        float: right;
        background: #00FF00;
        }

        .intro {
            clear: both;
            width: 584px;
            font-size: 14px;
            padding: 5px;
            display: block;
            background: #00FF00;
        }
于 2011-01-26T18:28:25.360 回答
0

正如我以前的小提琴中所展示的

http://jsfiddle.net/3YstS/9/ & http://jsfiddle.net/3YstS/10/

我发现 Opera 处理这个问题的方式存在一些严重的不一致,现在我认为这是 Opera 的一个错误。

但是找到了解决方案 http://jsfiddle.net/3YstS/13/

实际上是 CSS Float 引起了问题。当您卸下浮子时,问题就消失了。

问题解决了。


如果您需要将 .name div 向右对齐,则必须将其包装在应用 position:relative 的 div 中,然后将 position:absolute 和 right:0应用于 .name div。

像这样的东西

.new {
display: block;
width: 594px;
height: 100px;
position: relative;
border: 1px solid #000;
}
.bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}
.bottom div { 
    position:relative
}
.name {
    font-size: 15px;
    font-weight: bold;
    padding: 6px;
    position:absolute; right:0; top:-29px;
    background: #00FF00;
}        
.intro {
    clear: both;
    width: 584px;
    font-size: 14px;
    padding: 5px;
    display: block;
    background: #00FF00;
}

希望这对你们所有人都有帮助,甚至可能对 Opera 自己有所帮助。

于 2011-01-28T14:29:16.540 回答