【发布时间】:2013-12-26 04:14:04
【问题描述】:
我有一个适用于 Firefox 和 IE11 的简单代码,但它不适用于 Chrome。
这是一个简单的 div,当页面加载时它必须“淡入”并且“点击时”必须“淡出”。
这是代码:
HTML
<div class="BoxContainer">
<div class="Box " id="Box1">
<div class="LargeTile Tile Tile_SKY">
<div class="BoxTitle">
Search
</div>
</div>
</div>
</div>
CSS
.BoxContainer{
position:relative;
margin:auto;
margin-top:15%;
width: 100%;
height: 100%;
}
.Box{
position: absolute;
width: 200px;
height: 200px;
z-index: 1;
perspective: 1000;
}
#Box1
{
top:10px;
left:0px;
}
.Tile_SKY{
background:#2a7fed url('imgs/tiles/sky.png');
border:2px solid #4399f1;
}
.LargeTile{
position:absolute;
text-align:center;
width: 200px;
height: 200px;
}
.LargeTile .BoxTitle{
font-size:15px;
font-family:Tahoma;
color:#fff;
position: absolute;
left: 10px;
bottom: 5px;
}
.LargeTile .TileImage{
width: 45%;
height: 45%;
margin: 25% auto;
}
.fadeOutback{
animation: fadeOutback 0.3s ease-out 1 normal forwards;
}
.fadeInForward{
/*remember: in the second animation u have to set the final values reached by the first one*/
opacity:0;
transform: translateZ(-5em) scale(0.75);
animation: fadeInForward .25s cubic-bezier(.03,.93,.43,.77) .2s normal forwards;
}
@keyframes fadeOutback{
0% {transform: translateX(-2em) scale(1); opacity:1;}
70% {transform: translateZ(-5em) scale(0.6); opacity:0.5;}
95% {transform: translateZ(-5em) scale(0.6); opacity:0.5;}
100% {transform: translateZ(-5em) scale(0); opacity:0;}
}
@keyframes fadeInForward{
0% {transform: translateZ(-5em) scale(0); opacity:0;}
100% {transform: translateZ(0) scale(1); opacity:1;}
}
jQuery
$(document).ready(function(){
$('#Box1').addClass('fadeInForward').removeClass('fadeOutback');
$('.Tile').on('click',function(){
$('#Box1').removeClass('fadeInForward').addClass('fadeOutback');
});
});
【问题讨论】:
标签: jquery html css google-chrome