我创建了一个动画,使用 jQuery 模拟开门。它适用于 Firefox 24、Chrome 28 甚至 IE 8。但是,它不适用于 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。
任何想法将不胜感激!