jQuery slideToggle()在Chrome / Safari中的特殊行为 [英] jQuery slideToggle() peculiar behaviour in Chrome/Safari

查看:150
本文介绍了jQuery slideToggle()在Chrome / Safari中的特殊行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在slideToggle()和元素时遇到Chrome的问题。

I am having a problem in Chrome when I slideToggle() and element.

编辑:示例在这里,点击链接A几次,你会看到我的意思。

Example here, click Link A a few times and you'll see what I mean.

HTML是沿着的:

<div>
    <a>Link A</a>
    <a id="myLink">Link B</a>
</div>

使用非常简单的CSS将所有链接水平向左移动:

With very simple CSS floating all the links to the left horizontally:

a{
  float: left;
  margin-right: 20px;
  height: 20px;
  width: 20px;
}

#myLink{
   display: none; 
}

JavaScript简单地在显示myLink和在某些事件上隐藏它之间切换。 p>

The JavaScript simply toggles between showing myLink and hiding it on some event.

$('#myLink').slideToggle();

当slideToggle()第一次调用时,链接显示为与其他链接水平对齐。但是,如果我再次隐藏它,当它重新出现在Chrome / Safari中时,链接显示在其他链接(而不是旁边)的下面。此外,我注意到,如果我在Chrome中使用开发人员工具,并点击元素,它修复了自己,并将链接水平内联与其他链接。

When slideToggle() is called the first time, everything works nicely; the link appears horizontally aligned with the other link. However, if I hide it again, when it reappears in Chrome/Safari the link appears underneath the other link (instead of alongside it). Also, I've noticed if I use the Developer Tools in Chrome and click on the element, it fixes itself and moves the link to be horizontally inline with the other link.

任何人都知道与WebKit中的slideToggle()有任何问题?

Anyone know of any issues with slideToggle() in WebKit?

推荐答案

不要浮动 DIV 或者你可以给它一个宽度的像素。

Don't float DIV or you can give it a width in pixels.

这篇关于jQuery slideToggle()在Chrome / Safari中的特殊行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆