HTML5+CSS3从入门到精通 如何利用SVG和css3实现炫酷的边框动画
沉沙 2018-06-12 来源 : 阅读 889 评论 0

摘要:本篇教程讲解了如何利用SVG和css3实现炫酷的边框动画,希望阅读本篇文章以后大家有所收获,帮助大家HTML5+CSS3从入门到精通 。

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>line</title>
    </head>
    <style>
        .empat {
            position: relative;
            overflow: hidden;
            width: 200px;
            height: 200px;
            background-color: #ddd
        }
        svg {
            position: absolute;
            top: 0;
            left: 0;
            width: 200px;
            height: 200px
        }
        .empat svg line{
            stroke-width: 10;
            stroke: #000;
            fill: none;
            stroke-dasharray: 200;
            -webkit-transition: -webkit-transform .6s ease-out;
            transition: transform .6s ease-out;
        }
        .empat:hover svg line.top {
            -webkit-transform: translateX(-400px);
            transform: translateX(-400px);
        }
        .empat:hover svg line.left {
            -webkit-transform: translateY(400px);
            transform: translateY(400px);
        }
        .empat:hover svg line.bottom {
            -webkit-transform: translateX(400px);
            transform: translateX(400px);
        }
        .empat:hover svg line.right {
            -webkit-transform: translateY(-400px);
            transform: translateY(-400px);
        }
    </style>
    <body>
        <div>
            <svg>
                <line x1='0' y1='0' x2='600' y2='0'></line>
                <line x1='0' y1='200' x2='0' y2='-400'></line>
                <line x1='-400' y1='200' x2='200' y2='200'></line>
                <line x1='200' y1='600' x2='200' y2='0'></line>
            </svg>
        </div>
    </body>
    </html>```

    

    利用SVG实现边框效果

    <html>
<head>
    <title></title>
</head>
<style type="text/css">
    .aa{
        position: relative;
        width: 120px;
        height: 42px;
        color: #008fe4;
        text-align: center;
        line-height: 42px;
        webkit-transition: all .3s linear;
        transition: all .3s linear;
    }
    .aa:hover{
        background-color: transparent;
        color: #008fe4
    }
    .aa svg{
        position: absolute;
        top: -1px;
        left: -1px;
        width: 120px;
        height: 42px
    }
    .aa svg rect {
        stroke: #008fe4;
        stroke-width: 2px;
        stroke-dashoffset: 0;
        -webkit-transition: all .9s cubic-bezier(.19,1,.22,1);
        transition: all .9s cubic-bezier(.19,1,.22,1);
        stroke-dasharray: 324;
    }
    .aa:hover svg rect {
        stroke: #008fe4;
        stroke-width: 4px;
        stroke-dasharray: 90 210;
        stroke-dashoffset: -175;
    }
</style>
<body>
    <div>
        <svg><rect x="0" y="0" width="120" height="42" fill="none" stroke='#008fe4' stroke-width='4'></rect></svg>
        参与投票
    </div>
</body>
</html>

 

本文由职坐标整理发布,欢迎关注职坐标WEB前端HTML5/CSS3频道,获取更多WEB前端知识!

本文由 @沉沙 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程