简体   繁体   English

我的代码在Safari上不起作用

[英]My code doesn't work on Safari

viewing this fiddle in Google Chrome works fine and the slide down and up effect works, but in Safari it doesn't. 在Google Chrome浏览器中查看此小提琴效果很好,并且可以实现上下滑动效果,但在Safari中则不能。 What am I doing wrong? 我究竟做错了什么? Is it the jQuery or the css? 是jQuery还是CSS?

Here's the code: 这是代码:

jQuery: jQuery的:

$(function() {
  $('.dropdown').hide();
  $('.dropdown-toggle').click(function(e) {
    $('.dropdown').slideToggle(400);
    $('.dropdown-toggle').slideDown('active');
    $('.dropdown').toggleClass('is-active');
    return false;
  });
  $(document).click(function() {
    if ($('.dropdown').is(':visible')) {
      $('.dropdown', this).slideUp();
      $('.dropdown').removeClass('is-active');
    }
  });
});

CSS: CSS:

body {
  padding: 2em;
}
a {
  text-decoration: none;
  color: #000;
}
nav {
  position: relative;
}
.dropdown-toggle {
  padding: .5em 1em;
  background: #777;
  border-radius: .2em .2em 0 0;
}
.dropdown {
  position: absolute;
  margin-top: .5em;
  background: #777;
  min-width: 12em;
  padding: 0;
  top: 0;
  left: 0;
  -webkit-transform: translateY(-60px);
  -ms-transform: translateY(-60px);
  transform: translateY(-60px);
  transition: transform .3s
}
.dropdown.is-active {
  -webkit-transform: translateY(30px);
  -ms-transform: translateY(30px);
  transform: translateY(30px);
  display: block
}
ul.dropdown li {
  list-style-type: none;
}
ul.dropdown a {
  text-decoration: none;
  padding: .5em 1em;
  display: block;
}

HTML: HTML:

<nav><a class="dropdown-toggle" href="#" title="Menu">Menu</a>
  <ul class="dropdown">
    <li><a href="#">Menu Item</a>
    </li>
    <li><a href="#">Menu</a>
    </li>
    <li><a href="#">Settings</a>
    </li>
    <li><a href="#">Search</a>
    </li>
  </ul>
</nav>

Thanks! 谢谢!

I could not add a comment so I'll answer instead. 我无法添加评论,所以我会回答。

could you try with a higher version of safari to test compatibility. 您可以尝试使用更高版本的safari来测试兼容性吗?

could be due to the outdated javascript engine ? 可能是由于JavaScript引擎过时了吗?

IMO your question is confusing. 海事组织,您的问题令人困惑。 This sentence: 这个句子:

the slide down and up effect works, but in Safari it doesn't. 向下和向上滑动效果有效,但在Safari中则无效。

is misleading. 有误导性。 Actually, the transform property does work and it has the expected behaviour (it "slides down and up") both on your version of Safari (5.1.7) on Windows (I have just tested out) and on modern versions of Safari on OS X. 实际上, transform属性确实起作用,并且在Windows(我刚刚测试过)的Safari版本(5.1.7)和OS的现代版本的Safari上都具有预期的行为(“向下滑动”) X。

The CSS property transform is available on Safari since its 3.1 version, as you can check out here . 从Safari 3.1版本开始, CSS属性transform可用在Safari上,您可以在此处查看

What it is not working is the transtion effect. 无效的transtion效果。 For that one you need a more updated Safari, read here . 为此,您需要更新的Safari,请阅读此处

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM