css3动画怎样能从下往上慢慢升上去 代码怎么写

html-css010

css3动画怎样能从下往上慢慢升上去 代码怎么写,第1张

<!DOCTYPE html>

<html>

<head>

    <style>

        div

        {

            width:100px

            height:100px

            background:red

            position:absolute

            animation:myfirst 5s

            -webkit-animation:myfirst 5s

            animation-fill-mode: forwards

        }

        @-webkit-keyframes myfirst /* Safari and Chrome */

        {

            0%   {background:red left:500px bottom:50px}

            25%  {background:red left:500pxheight:130pxbottom:50px}

            50%  {background:red left:500px height:160pxbottom:50px}

            75%  {background:red left:500pxheight:190px bottom:50px}

            100% {background:red left:500px height:210pxbottom:50px}

        }

    </style>

</head>

<body>

<div></div>

</body>

</html>

这只是个演示的demo,方法就是这样,animation-fill-mode: forwards这一句给你解释下,这句就是当动画完成时,动画会停留在最后一帧。其他代码都比较简单,不懂随时问我。

希望能够帮助到你,望采纳!

创建动画序列,需要使用animation属性或其子属性,该属性允许配置动画时间、时长以及其他动画细节,但该属性不能配置动画的实际表现,动画的实际表现是由 @keyframes规则实现,具体情况参见使用keyframes定义动画序列小节部分。

transition也可实现动画。transition强调过渡,是元素的一个或多个属性发生变化时产生的过渡效果,同一个元素通过两个不同的途径获取样式,而第二个途径当某种改变发生(如hover)时才能获取样式,这样就会产生过渡动画。