我創建了一個動畫,模擬使用jQuery的開門。它適用於Firefox 24,Chrome 28甚至IE 8,但它在Safari上不起作用 - 門打開,但在原始門右側的動畫結尾處重新出現「關閉」門。jQuery動畫作品,但不是在Safari
的jQuery:
$('.obrtlcsdoor span a').mouseover(function(){
$(this).closest('div').children('.obrtlcsdoorimage')
.stop()
.animate({
marginLeft: 55,
width: 0
}, 500)
.height();
});
$('.obrtlcsdoor span a').mouseout(function(){
$(this).closest('div').children('.obrtlcsdoorimage')
.stop()
.animate({
marginLeft: 0,
width: 55
}, 500)
.height();
});
HTML:
<div class="obrtlcsdoor">
<div class="obrtlcsdoorimage">
<img src="http://example.com/images/e-door.png" />
</div>
<span>
<a href="http://example.com/">Contact Us</a>
</span>
</div>
CSS:
.obrtlcsdoor {
z-index: 10;
float: left;
display: block;
margin: 10px;
height: 100px;
width: 263px;
background: #ff6900 url('http://example.com/images/e-door-open.png') no-repeat top left;
overflow: hidden;
line-height: 100px;
}
.obrtlcsdoor span {
width: 188px;
padding: 0 10px 6px;
font: bold 21px/24px 'Cabin', Arial, sans-serif;
line-height: 24px;
display: inline-block;
vertical-align: middle;
text-align: center;
}
.obrtlcsdoor span a {
display: block;
}
.obrtlcsdoor span a:link,
.obrtlcsdoor span a:visited {
text-decoration: none;
color: #fff;
}
.obrtlcsdoor span a:hover {
text-decoration: none;
color: #ffba8a;
}
.obrtlcsdoorimage {
display: block;
float: left;
height: 100px;
width: 55px;
}
.obrtlcsdoorimage img {
width: 100%;
height: 100%;
}
我已經將它設置爲jsfiddle。
任何想法將不勝感激!
非常感謝Pandaiolo,太棒了。 CSS需要一些調整來使它保持文本的垂直對齊等,但是我可以看到我現在需要做的事情。我想,只是一個Safari的怪癖。 – user114671