CSS3不透明度在Safari,Chrome和ie中不起作用

时间:2013-03-25 04:30:06

标签: css3 animation opacity

我只能在firefox中预览。 请帮帮我。

Link to Fiddle

HTML

<div id="yamaha">
<div class="bg1"></div>
<div class="pic1"></div>
</div>

CSS

body { margin:auto; }
/*yamaha */
#yamaha { width:990px; height:450px; position:relative; opacity:0;  -moz-animation: yamaha 40s linear; }
#yamaha div { position:absolute; background: 0 0 no-repeat; }
#yamaha .bg1 { width:990px; height:450px; background:url("../images/bg1.jpg");-webkit-animation: bg1 2s linear;-moz-animation: bg1 2s linear;}
#yamaha .pic1 {
    width:990px;
    height:142px;
    background:url("../images/pic1.png");
    z-index:2;
    top:308px;
    opacity:0;
    -moz-animation: pic1 100s linear 2s;
}
/* Safari and Chrome */
@-webkit-keyframes yamaha {
    0% { opacity:0; }
    1% { opacity:1; }
    50% { opacity:1; }
    51% { opacity:0; }
    100%; { opacity:0; }
}
@-webkit-keyframes bg1 {
    0% { opacity:0; }
    100%; { opacity:1; }
}
@-webkit-keyframes pic1 {
    0% { -webkit-transform:scale(0); opacity:0; }
    1% { -webkit-transform:scale(1); opacity:1; }
    100%; { -webkit-transform:scale(1); opacity:1; }
}    

/* Firefox */
@-moz-keyframes yamaha {
    0% { opacity:0; }
    1% { opacity:1; }
    50% { opacity:1; }
    51% { opacity:0; }
    100%; { opacity:0; }
}
@-moz-keyframes bg1 {
    0% { opacity:0; }
    100%; { opacity:1; }
}
@-moz-keyframes pic1 {
    0% { -moz-transform:scale(0); opacity:0; }
    1% { -moz-transform:scale(1); opacity:1; }
    100%; { -moz-transform:scale(1); opacity:1; }
}    

非常感谢。

1 个答案:

答案 0 :(得分:0)

#yamaha {
         width:990px; 
         height:450px; 
         position:relative; 
         opacity:0;  
         -moz-animation: yamaha 40s linear; 
         -webkit-animation: yamaha 40s linear; /* Add this */
         animation: yamaha 40s linear; /* Add this */
         }
#yamaha .bg1 { 
         width:990px; 
         height:450px; 
         background:url("../images/bg1.jpg");
         -webkit-animation: bg1 2s linear;
         -moz-animation: bg1 2s linear;
         animation: bg1 2s linear; /* Add this */
         }

/* and add this */
@keyframes yamaha {
0% { opacity:0; }
1% { opacity:1; }
50% { opacity:1; }
51% { opacity:0; }
100%; { opacity:0; }
}
@keyframes bg1 {
0% { opacity:0; }
100%; { opacity:1; }
}
@keyframes pic1 {
0% { -webkit-transform:scale(0); opacity:0; }
1% { -webkit-transform:scale(1); opacity:1; }
100%; { -webkit-transform:scale(1); opacity:1; }
} 

我希望这会有所帮助