简单边框动画

在layui论坛上闲逛时发现了一个用css3实现的边框动画,故简单实现了下。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .container{position: relative;width: 200px;height: 100px;line-height: 100px;text-align: center;border: 1px solid #ccc;}
        span{position: absolute;display: inline-block;content: none;width: 0;height: 0;font-size: 0;border: 0;transition: .5s;}
        /*该动画实则是通过四个span标签分别设置边框,然后再增加宽度或者高度来实现的*/
        .top{top: 0;right: 0;border-top: 2px solid #000;}
        .right{bottom: 0;right: 0;border-right: 2px solid #000;}
        .bottom{bottom: 0;left: 0;border-bottom: 2px solid #000;}
        .left{top: 0;left: 0;border-left: 2px solid #000;}

        .container:hover .top,.container:hover .bottom{width: 200px;}
        .container:hover .left,.container:hover .right{height: 100px;}

        /*animate动画,因为上面运用了transition动画,故下面的动画注释了*/
        /*.top,.bottom{animation: bt .6s infinite ease-in-out;}
        .left,.right{animation: bl .6s infinite ease-in-out}*/
        @keyframes bt{
            from{
                width: 0;
            }
            25%{
                width: 50px;
            }
            50%{
                width: 100px;
            }
            75{
                width: 150px;
            }
            to{
                width: 200px;
            }
        }

        @keyframes bl{
            from{
                height: 0;
            }
            25%{
                height: 25px;
            }
            50%{
                height: 50px;
            }
            75%{
                height: 75px;
            }
            to{
                height: 100px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        KOBE BRYANT
        <span class="top"></span>
        <span class="right"></span>
        <span class="bottom"></span>
        <span class="left"></span>
    </div>
</body>
</html>

也可以看看这篇文章

时间: 2024-10-13 12:10:07

简单边框动画的相关文章

cocos2d-x ios游戏开发初认识(七) 简单的动画

前面有一节说了帧动画,就是让精灵改变自己的位置.形状.大小来实现相应的动作,这讲主要是要通过一些方法来实现精灵的移动,产生各种炫丽的动画,也可能让你找到一点游戏场景. 下面具体根据代码分析: 为了清晰最好将前几节的代码注释掉. //根据前面的知识先创建一个菜单 CCMenuItemFont *item =CCMenuItemFont::create("开始游戏",this, menu_selector(MainScene::onMenuItem));//点击事件 //添加到菜单栏里面

css3 简单界面动画

asdasdasdasda asdasdasdasdacss3 简单界面动画,布布扣,bubuko.com

文顶顶 iOS开发UI篇—iOS开发中三种简单的动画设置

iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 [UIView setAnimationDuration:2.0]; self.headImageView.bounds = rect; // commitAnimations,将beginAnimation之后的所

6种炫酷的CSS3按钮边框动画特效

这是一款效果非常炫酷的CSS3按钮边框动画特效.这组按钮边框动画共有6种不同的效果.当鼠标滑过按钮的时候,按钮的边框会以不同的方式进行各种动画,效果非常的炫酷. 在线预览   源码下载 使用方法 HTML结构 该CSS3按钮边框动画特效中的按钮使用HTML的<button>元素来制作.各种效果非标设置不同的class.例如第一种效果的class为draw. <button class="draw">draw</button> CSS样式 在CSS样式

iOS开发UI篇—iOS开发中三种简单的动画设置

iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 [UIView setAnimationDuration:2.0]; self.headImageView.bounds = rect; // commitAnimations,将beginAnimation之后的所

iOS开发-三种简单的动画设置

[在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 [UIView setAnimationDuration:2.0]; self.headImageView.bounds = rect; // commitAnimations,将beginAnimation之后的所有动画提交并生成动画 [UIView commit

简单的动画队列模型

给新手写了一个便于理解的动画链式 var anmin = {} anmin.list = []; anmin.run = function(nextfun){ anmin.list.push(nextfun); //加入动画正在触发 (function fire() { if (!anmin.fireing) { var onceRun = anmin.list.shift() if (onceRun) { anmin.fireing = true; onceRun(function() { a

canvas画简单圆形动画

HTML: 1 <html> 2 <head> 3 <title>canvas画圆</title> 4 <meta http-equiv="content-type" content="text/html" charset="utf-8"> 5 <link rel="stylesheet" href="circle.css"/> 6 &

iOS开发中三种简单的动画设置

iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 [UIView setAnimationDuration:2.0]; self.headImageView.bounds = rect; // commitAnimations,将beginAnimation之后的所有动画提交并生成动