Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 不带悬停的Webkit转换_Html_Css - Fatal编程技术网

Html 不带悬停的Webkit转换

Html 不带悬停的Webkit转换,html,css,Html,Css,我制作了以下简单的动画,其中一个图像在鼠标悬停时生长,但我真正想要的是它在没有悬停的情况下发生,即当页面加载时 HTML 我试着使用下面的方法,但没有效果 from {width: 160px; height: 400px;} to {width: 200px; height: 500px;} 要么是走错了路,要么是我放错了地方。给你: animation: imganim 1s infinite linear both; @keyframes imganim { from {width:

我制作了以下简单的动画,其中一个图像在鼠标悬停时生长,但我真正想要的是它在没有悬停的情况下发生,即当页面加载时

HTML

我试着使用下面的方法,但没有效果

from {width: 160px; height: 400px;}
to {width: 200px; height: 500px;} 

要么是走错了路,要么是我放错了地方。

给你:

animation: imganim 1s infinite linear both;

@keyframes imganim {
from {width: 160px; height: 400px;}
to {width: 200px; height: 500px;} 
}
@keyframes imganim {
0% {width: 160px; height: 400px;}
50% {width: 200px; height: 500px;}
100% {width: 160px; height: 400px;}
}

对于循环动画,请使用以下命令:

animation: imganim 1s infinite linear both;

@keyframes imganim {
from {width: 160px; height: 400px;}
to {width: 200px; height: 500px;} 
}
@keyframes imganim {
0% {width: 160px; height: 400px;}
50% {width: 200px; height: 500px;}
100% {width: 160px; height: 400px;}
}

注意事项:

animation: imganim 1s infinite linear both;

@keyframes imganim {
from {width: 160px; height: 400px;}
to {width: 200px; height: 500px;} 
}
@keyframes imganim {
0% {width: 160px; height: 400px;}
50% {width: 200px; height: 500px;}
100% {width: 160px; height: 400px;}
}
  • 对于
    动画
  • 对于定义动画,应使用关键帧
  • 所有现代浏览器都已阅读
    动画
    过渡
    ,无需使用
    -webkit-
    -moz-

您想要的是
动画,而不是
过渡
。在要播放动画的元素上,为动画指定名称(即animate),并将动画变量放入该关键帧动画中。完整布局见下文。不要忘记供应商的前缀

/*成长动画*/
.成长img{
位置:绝对位置;
底部:0;
高度:400px;
宽度:160px;
-webkit动画:制作5s轻松动画;
动画:设置5s轻松动画;
}
@-webkit关键帧动画{
从{
宽度:160px;
高度:400px;
}
到{
宽度:200px;
高度:500px;
} 
}
@关键帧设置动画{
从{
宽度:160px;
高度:400px;
}
到{
宽度:200px;
高度:500px;
} 
}

您需要在CSS中包含@关键帧持续时间,如下所示:

@keyframes example {
  from {background-color: red;}
  to {background-color: yellow;}
}

/* The element to apply the animation to */
div {
  width: 100px;
  height: 100px;
  background-color: red;
  animation-name: example;
  animation-duration: 4s;
}

将颜色值替换为所需的高度/宽度值。

解决方案如下:未正确编写转换规则以获得该行为

.grow img{
位置:绝对位置;
底部:0;
高度:400px;
宽度:160px;
动画计时功能:轻松;
/*-webkit过渡:fadein所有5s;
-moz过渡:fadein所有5s;
-o-过渡:所有5s内均为fadein;
-ms过渡:fadein所有5s;
过渡:fadein所有5s*/
动画名称:fadein;
动画持续时间:4s;
}
@关键帧淡入淡出{
从{宽度:160px;高度:400px;}
至{宽度:200px;高度:500px;}
}
/*Firefox<16*/
@-moz关键帧fadein{
从{宽度:160px;高度:400px;}
至{宽度:200px;高度:500px;}
}
/*Safari、Chrome和Opera>12.1*/
@-webkit关键帧fadein{
从{宽度:160px;高度:400px;}
至{宽度:200px;高度:500px;}
}
/*Internet Explorer*/
@-ms关键帧fadein{
从{宽度:160px;高度:400px;}
至{宽度:200px;高度:500px;}
}
/*歌剧<12.1*/
@-o-关键帧fadein{
从{宽度:160px;高度:400px;}
至{宽度:200px;高度:500px;}
}