javascript - Pourquoi mon paramètre de mode de remplissage d'animation ne prend-il pas effet
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-05 10:39:25
0
2
974

.gold_egg_broken{

background: url("../img/animation/goldeggBroke.png");
width: 400px;
height: 400px;
animation: eggbroken 3s;
-webkit-animation-fill-mode:forwards;
-webkit-animation-timing-function: steps(80);

}

@-webkit-keyframes eggbroken {

0%{
    background-position: 0 0;
}
90%{
    background-position: 0 -32000px;
}
100%{
    background-position: 0 -32000px;
}

}

Basculez dynamiquement ce style sur un élément et souhaitez qu'il reste inchangé sur la dernière image. Mais ça ne marche pas

女神的闺蜜爱上我
女神的闺蜜爱上我

répondre à tous(2)
阿神

Supprimez le préfixe webkit et modifiez-le comme suit :

.gold_egg_broken{
    background: url("../img/animation/goldeggBroke.png");
    width: 400px;
    height: 400px;
    animation: eggbroken 3s;
    animation-fill-mode:forwards;
    animation-timing-function: steps(80);
}

Étant donné que l'attribut d'animation fonctionne, cela signifie que les attributs associés n'ont pas besoin d'être préfixés dans ce navigateur. animation是一个综合属性,默认的animation-fill-modenone,使用带前缀的属性webkit-animation-fill-mode不能覆盖掉animation-fill-mode, le préfixe doit donc être supprimé.

Ty80

Merci pour l'invitation,
@luckness l'a dit très clairement.
De plus, les préfixes tels que webkit doivent être compatibles avec différentes versions de différents navigateurs.
Une manière plus conservatrice de l'écrire peut être :

.
p{
     -webkit-animation-fill-mode: forwards;
        -moz-animation-fill-mode: forwards;
         -ms-animation-fill-mode: forwards;
          -o-animation-fill-mode: forwards;
             animation-fill-mode: forwards;
}
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!