这款导航概念在Chrome和Firefox中运行良好,但在Safari中非常抢眼。在然后正常运行之前,似乎首先在Safari中进行一半动画制作。有什么想法吗?
<ul id="navigation">
<a href="#"><li id="first"><span id="logo"></span><span class="navigation-text">Home</span></li></a>
<a href="#"><li class="standard"><span class="gallery_icon"></span><span class="navigation-text">Gallery</span></li></a>
<a href="#"><li class="standard"><span></span><span class="navigation-text">Gallery</span></li></a>
<a href="#"><li class="standard"><span></span><span class="navigation-text">GalleryGallery123</span></li></a>
<li id="last" class="standard"></li>
</ul>
<script type="text/javascript">
$(document).ready(function() {
// On hover:
$('#navigation li').hoverIntent(function () {
width = $(this).children('span:nth-child(2)').width();
text = $(this).children('span:nth-child(2)');
var newwidth = (width + 15) // Original width + 15px padding
text.filter(':not(:animated)').animate({"width":"0px"}, 0).show(); // Make the width 0px and make the element visible
text.animate({"width":+newwidth+"px"}, 300); // Animate the width to the new size
},
function () {
text.filter(':not(:animated)').animate({"width":"0px"}, 150); // Animate the width to 0px and hide the element
text.animate({"width":+width+"px","float":"left"}, 0);
setTimeout(function() {
text.hide();
},100);
});
});
</script>
的jsfiddle:
答案 0 :(得分:2)
原来,Safari不喜欢动画为0px。将0px更改为1px将动画分类闪烁:)