Opera 和 SlideToggle() 的 jQuery 奇怪问题

发布于 2024-10-14 06:28:36 字数 431 浏览 7 评论 0原文

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

这是我的代码:

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

和链接:

某物的名称 某事的介绍

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

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

I have a weird problem with jQuery and Opera. When I am using slideToggle(), it runs fine and smooth in Firefox, Chorme, Safari and even in IE, but not in Opera. In Opera the motion is kind of broken: first it moves a little, then it stops and finally it jumps straight to end.

Here is my code:

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

And the link:

The name of something

The introduction of something

The oddest problem is there: when I add another link (same than the other, expect other id), then Opera loads both intro-spans fine. But with only one intro-span, it isn't smooth.

The code is now on jsFiddle too (http://jsfiddle.net/3YstS/6).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铃予 2024-10-21 06:28:36

所示

正如我之前的小提琴http://jsfiddle.net/3YstS/9/
http://jsfiddle.net/3YstS/10/

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

不过已经找到解决办法了
http://jsfiddle.net/3YstS/13/

实际上是 CSS Float 导致了问题。当你移除浮子时,问题就消失了。

问题已解决。


如果您需要将 .name div 向右对齐,则必须将其包装在应用了position:relative的div中,然后然后应用位置:绝对和 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 本身有帮助。

As demonstrated in my previous fiddles

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

I found that there is some serious inconsistency in the way Opera handles this, for now I'll consider this to be a bug with opera.

However have found a solution
http://jsfiddle.net/3YstS/13/

It is actually the CSS Float which causes an issue. When you remove the float the problem goes away.

Problem Solved.


If you need to align the .name div to the right you must wrap it in a div with position:relative applied, and then apply position:absolute and right:0 to the .name div.

Something like this

.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;
}

Hope this is of some help to you all ,and maybe even Opera themselves.

无声静候 2024-10-21 06:28:36

评论中Blowsie的测试表明确实存在bug。奇怪的行为。您是否在 Opera bug 向导上报告了该问题?

在这里发布好的代码,以便人们在 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;
        }

The tests of Blowsie in the comments show indeed that there is a bug. Strange behavior. Did you report it on Opera bug wizard.

Posting here the good code so people have a reference in case jsfiddle disappears.

JAVASCRIPT

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

HTML code

    <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 Code

.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;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文