css3文本框里面的东西自动上下移动

html-css014

css3文本框里面的东西自动上下移动,第1张

可以用定义动画的方法,animation 动画名 时间 曲线 如何运动(设置无限循环)

@keyfram 动画名 {

设置盒子的margin值

margin-top:0;

margin-top:40px;

<!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这一句给你解释下,这句就是当动画完成时,动画会停留在最后一帧。其他代码都比较简单,不懂随时问我。

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

@-webkit-keyframes bounce-down {

  25% {

    -webkit-transform: translateY(-3px)

  }

  50%, 100% {

    -webkit-transform: translateY(0)

  }

  75% {

    -webkit-transform: translateY(3px)

  }

}

@keyframes bounce-down {

  25% {

    transform: translateY(-3px)

  }

  50%, 100% {

    transform: translateY(0)

  }

  75% {

    transform: translateY(3px)

  }

}

.animate-bounce-down{

  -webkit-animation: bounce-down 1.3s linear infinite

  animation: bounce-down 1.3s linear infinite

}

如果不考虑低版本兼容,css3动画可以简单实现,给需要漂浮的元素添加animate-bounce-down这个类就好,浮动效果可以自行调试