CSS3按钮各种线性动画环绕线动画

 

css3 中间向两边出线


<a href="http://www.79bk.cn/">一组菜单按钮边线交互动画集合</a>

body {
    background: black
}
a {
    color: whitesmoke;
    text-transform: uppercase;
    text-decoration: none;
    letter-spacing: .15em;
    display: inline-block;
    padding: 15px 20px;
    font-size: 28px;
    position: relative
}
a:after {
    background: none repeat scroll 0 0 transparent;
    bottom: 0;
    content: "";
    display: block;
    height: 2px;
    left: 50%;
    position: absolute;
    background: #65a835;
    transition: width .3s ease 0s, left .3s ease 0s;
    width: 0
}
a:hover:after {
    width: 100%;
    left: 0
}

CSS3 按钮悬停边框变换动效


<div class='box foo'>
    乔
</div>
<div class='box bar'>
    越
</div>
<div class='box curmudgeon'>
    博客
</div>



* {
    font-family: sans-serif;
    font-weight: 100;
    font-size: 20px;
}
body {
    background-color: #3fb;
    text-align: center;
    line-height: 100vh;
}
.box {
    position: relative;
    vertical-align: middle;
    color: #0b7;
    display: inline-block;
    height: 60px;
    line-height: 60px;
    text-align: center;
    -webkit-transition: 0.5s;
    transition: 0.5s;
    padding: 0 20px;
    cursor: pointer;
    border: 2px solid #0b7;
    -webkit-transition: 0.5s;
}
.box:hover {
    border: 2px solid rgba(0, 160, 80, 0);
    color: #fff;
}
.box::before,
.box::after {
    width: 100%;
    height: 100%;
    z-index: 3;
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    -webkit-transform: scale(0);
    -webkit-transition: 0.5s;
    transition: 0.5s;
}
.foo::before {
    border-bottom: 3px solid #fff;
    border-left: 3px solid #fff;
    -webkit-transform-origin: 0 100%;
}
.foo::after {
    border-top: 3px solid #fff;
    border-right: 3px solid #fff;
    -webkit-transform-origin: 100% 0%;
}
.bar::before {
    border-bottom: 3px solid #fff;
    border-left: 3px solid #fff;
    -webkit-transform-origin: 100% 0%;
}
.bar::after {
    border-top: 3px solid #fff;
    border-right: 3px solid #fff;
    -webkit-transform-origin: 0% 100%;
}
.curmudgeon::before {
    border-bottom: 3px solid #fff;
    border-left: 3px solid #fff;
    -webkit-transform-origin: 50% 50%;
}
.curmudgeon::after {
    border-top: 3px solid #fff;
    border-right: 3px solid #fff;
    -webkit-transform-origin: 50% 50%;
}
.box:hover::after,
.box:hover::before {
    -webkit-transform: scale(1);
}

 

SVG CSS3 按钮悬停边线环绕+波浪线+选择框动效


<span class="title">乔越博客</span>
<div class="basicBox">
    Hover
    <svg width="130" height="65" viewBox="0 0 130 65" xmlns="http://www.w3.org/2000/svg">
        <rect x='0' y='0' fill='none' width='130' height='65' />
    </svg>
</div>

<span class="title">乔越博客</span>
<div class="swiggleBox">
    Hover
    <svg width="130" height="65" viewBox="0 0 130 65" xmlns="http://www.w3.org/2000/svg">
        <path d="M0.6,0.5c0,5.4,0,61.5,0,61.5s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0
	s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0
	c5.4-5.4,9.9,0,9.9,0s4.5,5.4,9.9,0c0,0,0-56.1,0-61.5H0.6z" />
    </svg>
</div>

<span class="title">乔越博客</span>
<div class="checkBox">
    Hover
    <svg width="140" height="65" viewBox="0 0 140 65" xmlns="http://www.w3.org/2000/svg">
        <rect x="10" class="button" width="128.8" height="63.9" />
        <rect x="0" y="22.5" class="box" width="20" height="20" />
        <polyline class="checkMark" points="4.5,32.6 8.7,36.8 16.5,29.1" />
    </svg>
</div>
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
*,
*::before,
*::after {
    box-sizing: border-box;
}
body {
    background: #fdfdfd;
    margin: 25px 0;
}
span.title {
    margin: 0 auto;
    color: #bbb;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.85rem;
    text-align: center;
    display: block;
}
.basicBox,
.swiggleBox,
.checkBox {
    width: 130px;
    height: 65px;
    margin: 15px auto;
    color: #4274d3;
    font-family: 'Open Sans', sans-serif;
    font-size: 1.15rem;
    line-height: 65px;
    text-transform: uppercase;
    text-align: center;
    position: relative;
    cursor: pointer;
}
svg {
    position: absolute;
    top: 0;
    left: 0;
}
svg rect,
svg path,
svg polyline {
    fill: none;
    stroke: #4274d3;
    stroke-width: 1;
}
.basicBox:hover svg rect,
.swiggleBox:hover svg path,
.checkBox:hover svg polyline {
    stroke: #4274d3;
    /* Basic Box */
}
svg rect {
    stroke-dasharray: 400, 0;
    -webkit-transition: all 0.8s ease-in-out;
    -moz-transition: all 0.8s ease-in-out;
    -ms-transition: all 0.8s ease-in-out;
    -o-transition: all 0.8s ease-in-out;
}
.basicBox:hover svg rect {
    stroke-width: 3;
    stroke-dasharray: 35, 245;
    stroke-dashoffset: 38;
    -webkit-transition: all 0.8s ease-in-out;
    -moz-transition: all 0.8s ease-in-out;
    -ms-transition: all 0.8s ease-in-out;
    -o-transition: all 0.8s ease-in-out;
    /* Swiggle Box */
}
svg path {
    stroke-dasharray: 265, 0;
    -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -ms-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
}
.swiggleBox:hover svg path {
    stroke-width: 3;
    stroke-dasharray: 0, 350;
    stroke-dashoffset: 20;
    -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -ms-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
    /* Check Box */
}
.checkBox svg {
    margin-left: -10px;
}
.checkBox svg rect,
.checkBox svg polyline {
    fill: none;
    stroke: #4274d3;
    stroke-width: 1;
    -webkit-transition: all 0.8s ease-in-out;
    -moz-transition: all 0.8s ease-in-out;
    -ms-transition: all 0.8s ease-in-out;
    -o-transition: all 0.8s ease-in-out;
}
.checkBox:hover svg rect {
    stroke-width: 2;
    -webkit-transition: all 0.8s ease-in-out;
    -moz-transition: all 0.8s ease-in-out;
    -ms-transition: all 0.8s ease-in-out;
    -o-transition: all 0.8s ease-in-out;
}
.checkBox:hover svg polyline {
    stroke-width: 2;
    -webkit-transition: all 0.8s ease-in-out;
    -moz-transition: all 0.8s ease-in-out;
    -ms-transition: all 0.8s ease-in-out;
    -o-transition: all 0.8s ease-in-out;
}
.checkBox svg .button {
    stroke-dasharray: 400px, 0;
}
.checkBox:hover svg .button {
    stroke-dasharray: 0, 400px;
    stroke-dashoffset: 33px;
    /* Check Mark Effect */
}
.box,
.checkMark {
    opacity: 0;
}
.checkBox:hover .box {
    -webkit-animation: boxDisplay 0.2s forwards;
    -moz-animation: boxDisplay 0.2s forwards;
    -ms-animation: boxDisplay 0.2s forwards;
    -o-animation: boxDisplay 0.2s forwards;
    animation: boxDisplay 0.2s forwards;
    -webkit-animation-delay: 0.65s;
    -moz-animation-delay: 0.65s;
    -ms-animation-delay: 0.65s;
    -o-animation-delay: 0.65s;
    animation-delay: 0.65s;
}
.checkBox:hover .checkMark {
    -webkit-animation: checkDisplay 0.2s forwards;
    -moz-animation: checkDisplay 0.2s forwards;
    -ms-animation: checkDisplay 0.2s forwards;
    -o-animation: checkDisplay 0.2s forwards;
    animation: checkDisplay 0.2s forwards;
    -webkit-animation-delay: 1s;
    -moz-animation-delay: 1s;
    -ms-animation-delay: 1s;
    -o-animation-delay: 1s;
    animation-delay: 1s;
    /* Check Box Display */
}
@-webkit-keyframes boxDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-moz-keyframes boxDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-ms-keyframes boxDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-o-keyframes boxDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@keyframes boxDisplay {
    /* Check Mark Display */
    
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-webkit-keyframes checkDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-moz-keyframes checkDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-ms-keyframes checkDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@-o-keyframes checkDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
@keyframes checkDisplay {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

CSS3 竖向菜单和边线环绕动效


<div class="btn-menu-container">
    <a href="#" class="btn-menu btn-outlined">
                m<br />
                e<br />
                n<br />
                u<br />
                <span class="line top"></span>
                <span class="line right"></span>
                <span class="line bottom"></span>
                <span class="line left"></span>
            </a>
</div>




html {
    color: #222;
    font-size: 62.5%;
    line-height: 1.4;
    background-color: #f0f0f0;
}
::-moz-selection {
    background: #b3d4fc;
    text-shadow: none;
}
::selection {
    background: #b3d4fc;
    text-shadow: none;
}
hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;
}
audio,
canvas,
iframe,
img,
svg,
video {
    vertical-align: middle;
}
fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}
textarea {
    resize: vertical;
}
a {
    text-decoration: none;
}
a,
a span {
    -webkit-transition-duration: 0.45s;
    -webkit-transition-property: color, border-color, background-color, opacity;
    -webkit-transition-delay: 0s;
    -webkit-transition-timing-function: 'ease-in-out';
    transition-duration: 0.45s;
    transition-property: color, border-color, background-color, opacity;
    transition-delay: 0s;
    transition-timing-function: 'ease-in-out';
   
}
.btn-menu-container {
    text-align: center;
    width: 10%;
    z-index: 20;
    margin: 25% auto;
}
.btn-menu-container .btn-menu {
    transform: translate3d(0, -50%, 0) translate(0);
    backface-visibility: hidden;
    -webkit-transform: translate3d(0, -50%, 0) translate(0);
    -webkit-backface-visibility: hidden;
    -webkit-text-stroke: 1px rgba(120, 119, 114, .1);
    font-family: 'Brandon Grotesque', sans-serif;
    font-weight: 300;
    font-size: 5em;
    text-transform: uppercase;
    display: inline-block;
    position: relative;
    color: #0d091b;
    line-height: 1em;
    padding: 25px;
}
.btn-outlined {
    border: 1px solid transparent;
    -webkit-transition: all 250ms ease-in-out;
    -moz-transition: all 250ms ease-in-out;
    -ms-transition: all 250ms ease-in-out;
    -o-transition: all 250ms ease-in-out;
    transition: all 250ms ease-in-out;
}
.btn-outlined:hover {
    font-weight: 700;
}
.btn-outlined .line {
    -webkit-transition-duration: 0.45s;
    -webkit-transition-property: top, right, bottom, left, width, height;
    -webkit-transition-delay: 0s;
    -webkit-transition-timing-function: 'ease-in-out';
    transition-duration: 0.45s;
    transition-property: top, right, bottom, left, width, height;
    transition-delay: 0s;
    transition-timing-function: 'ease-in-out';
    display: block;
    position: absolute;
    background: #0d091b;
}
.btn-outlined .line.top {
    left: 1%;
    top: 1%;
    width: 0;
    height: 0.01em;
    background: #8f8f8f;
}
.btn-outlined:hover .line.top {
    background: #64d2b4;
    width: 98%;
    height: 0.125em;
}
.btn-outlined .line.right {
    right: 1%;
    top: 1%;
    width: 0.01em;
    height: 0;
    background: #8f8f8f;
}
.btn-outlined:hover .line.right {
    background: #64d2b4;
    height: 98%;
    width: 0.125em;
}
.btn-outlined .line.bottom {
    right: 1%;
    bottom: 1%;
    width: 0;
    height: 0.01em;
    background: #8f8f8f;
}
.btn-outlined:hover .line.bottom {
    background: #64d2b4;
    width: 98%;
    height: 0.125em;
}
.btn-outlined .line.left {
    left: 1%;
    bottom: 1%;
    width: 0.01em;
    height: 0;
    background: #8f8f8f;
}
.btn-outlined:hover .line.left {
    background: #64d2b4;
    height: 98%;
    width: 0.125em;
}

CSS3 鼠标悬停边线环绕按钮动效


<div class='btn-cont'>
    <a class='btn' href='#'>
    Learn More
    <span class='line-1'></span>
    <span class='line-2'></span>
    <span class='line-3'></span>
    <span class='line-4'></span>
  </a>
</div>



body {
    height: 100%;
    width: 100%;
    background-color: black;
}
.btn-cont {
    text-align: center;
    margin-top: 200px;
}
.btn-cont .btn {
    position: relative;
    padding: 20px 70px;
    border: 1px solid white;
    color: white;
    text-decoration: none;
    font-size: 1.125em;
    font-family: 'Open Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    -webkit-font-smoothing: antialiased;
}
.btn-cont .btn:hover {
    border: none;
}
.btn-cont .btn:hover .line-1 {
    -webkit-animation: move1 1500ms infinite ease;
    animation: move1 1500ms infinite ease;
}
.btn-cont .btn:hover .line-2 {
    -webkit-animation: move2 1500ms infinite ease;
    animation: move2 1500ms infinite ease;
}
.btn-cont .btn:hover .line-3 {
    -webkit-animation: move3 1500ms infinite ease;
    animation: move3 1500ms infinite ease;
}
.btn-cont .btn:hover .line-4 {
    -webkit-animation: move4 1500ms infinite ease;
    animation: move4 1500ms infinite ease;
}
.btn-cont .line-1 {
    content: "";
    display: block;
    position: absolute;
    width: 1px;
    background-color: white;
    left: 0;
    bottom: 0;
}
.btn-cont .line-2 {
    content: "";
    display: block;
    position: absolute;
    height: 1px;
    background-color: white;
    left: 0;
    top: 0;
}
.btn-cont .line-3 {
    content: "";
    display: block;
    position: absolute;
    width: 1px;
    background-color: white;
    right: 0;
    top: 0;
}
.btn-cont .line-4 {
    content: "";
    display: block;
    position: absolute;
    height: 1px;
    background-color: white;
    right: 0;
    bottom: 0;
}
@-webkit-keyframes move1 {
    0% {
        height: 100%;
        bottom: 0;
    }
    54% {
        height: 0;
        bottom: 100%;
    }
    55% {
        height: 0;
        bottom: 0;
    }
    100% {
        height: 100%;
        bottom: 0;
    }
}
@keyframes move1 {
    0% {
        height: 100%;
        bottom: 0;
    }
    54% {
        height: 0;
        bottom: 100%;
    }
    55% {
        height: 0;
        bottom: 0;
    }
    100% {
        height: 100%;
        bottom: 0;
    }
}
@-webkit-keyframes move2 {
    0% {
        width: 0;
        left: 0;
    }
    50% {
        width: 100%;
        left: 0;
    }
    100% {
        width: 0;
        left: 100%;
    }
}
@keyframes move2 {
    0% {
        width: 0;
        left: 0;
    }
    50% {
        width: 100%;
        left: 0;
    }
    100% {
        width: 0;
        left: 100%;
    }
}
@-webkit-keyframes move3 {
    0% {
        height: 100%;
        top: 0;
    }
    54% {
        height: 0;
        top: 100%;
    }
    55% {
        height: 0;
        top: 0;
    }
    100% {
        height: 100%;
        top: 0;
    }
}
@keyframes move3 {
    0% {
        height: 100%;
        top: 0;
    }
    54% {
        height: 0;
        top: 100%;
    }
    55% {
        height: 0;
        top: 0;
    }
    100% {
        height: 100%;
        top: 0;
    }
}
@-webkit-keyframes move4 {
    0% {
        width: 0;
        right: 0;
    }
    55% {
        width: 100%;
        right: 0;
    }
    100% {
        width: 0;
        right: 100%;
    }
}
@keyframes move4 {
    0% {
        width: 0;
        right: 0;
    }
    55% {
        width: 100%;
        right: 0;
    }
    100% {
        width: 0;
        right: 100%;
    }
}

SVG CSS3 按钮悬停边线环绕动画


<div class="btn">
    <svg>
        <rect x="0" y="0" fill="none" width="166" height="45" />
    </svg>
    Watch video
</div>






body {
    background-color: #494949;
    padding-top: 50px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
}
* {
    box-sizing: border-box;
}
.btn {
    position: relative;
    display: inline-block;
    width: 166px;
    height: 45px;
    font-size: 14px;
    line-height: 45px;
    text-align: center;
    text-transform: uppercase;
    color: #fff;
    cursor: pointer;
    overflow: hidden;
}
.btn svg {
    position: absolute;
    top: 0;
    left: 0;
}
.btn svg rect {
    fill: none;
    stroke: #fff;
    stroke-width: 6;
    stroke-dasharray: 422, 0;
    -webkit-transition: all 900ms cubic-bezier(0.19, 1, 0.22, 1);
    -moz-transition: all 900ms cubic-bezier(0.19, 1, 0.22, 1);
    transition: all 900ms cubic-bezier(0.19, 1, 0.22, 1);
}
.btn:hover svg rect {
    stroke-width: 10;
    stroke-dasharray: 110, 312;
    stroke-dashoffset: 183;
}

CSS3 链接悬停边框动效集合


<div class="wrapper">
    <a class="first after" href="#">Left to Right</a>
</div>
<div class="wrapper">
    <a class="second after" href="#">Right to Left</a>
</div>
<div class="wrapper">
    <a class="third after" href="#">Start Centered</a>
</div>
<div class="wrapper">
    <a class="fourth before after" href="#">Top & Bottom // Left to Right</a>
</div>
<div class="wrapper">
    <a class="fifth before after" href="#">Top & Bottom // Right to Left</a>
</div>
<div class="wrapper">
    <a class="sixth before after" href="#">Top & Bottom // Start Centered</a>
</div>
<div class="wrapper">
    <a class="seventh before after" href="#">Top & Bottom // Opposite Start</a>
</div>
<div class="wrapper">
    <a class="eigth before after" href="#">Top & Bottom // Opposite Start Reversed</a>
</div>
<div class="wrapper">
    <span class="square individual">
    <a class="ninth before after" href="#">Cool Square</a>
  </span>
</div>
<div class="wrapper">
    <span class="square">
    <a class="tenth before after" href="#">Cool Square Simultaneous</a>
  </span>
</div>
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
body {
    font-family: 'Open Sans', sans-serif;
    background: #151837;
    width: 90%;
    margin: 0 auto;
    padding: 2em 0 6em;
}
h1:before {
    content: "// ";
}
h1 {
    font-size: 3em;
    color: #fefefe;
    text-transform: lowercase;
}
.wrapper {
    margin: 3em 0;
}
a,
a:visited,
a:hover,
a:active {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    position: relative;
    transition: 0.5s color ease;
    text-decoration: none;
    color: #81b3d2;
    font-size: 2.5em;
}
a:hover {
    color: #d73444;
}
a.before:before,
a.after:after {
    content: "";
    transition: 0.5s all ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    position: absolute;
}
a.before:before {
    top: -0.25em;
}
a.after:after {
    bottom: -0.25em;
}
a.before:before,
a.after:after {
    height: 5px;
    height: 0.35rem;
    width: 0;
    background: #d73444;
}
a.first:after {
    left: 0;
}
a.second:after {
    right: 0;
}
a.third:after,
a.sixth:before,
a.sixth:after {
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
}
a.fourth:before,
a.fourth:after {
    left: 0;
}
a.fifth:before,
a.fifth:after {
    right: 0;
}
a.seventh:before {
    right: 0;
}
a.seventh:after {
    left: 0;
}
a.eigth:before {
    left: 0;
}
a.eigth:after {
    right: 0;
}
a.before:hover:before,
a.after:hover:after {
    width: 100%;
}
.square {
    box-sizing: border-box;
    margin-left: -0.4em;
    position: relative;
    font-size: 2.5em;
    overflow: hidden;
}
.square a {
    position: static;
    font-size: 100%;
    padding: 0.2em 0.4em;
}
.square:before,
.square:after {
    content: "";
    box-sizing: border-box;
    transition: 0.25s all ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    position: absolute;
    width: 5px;
    width: 0.35rem;
    height: 0;
    background: #d73444;
}
.square:before {
    left: 0;
    bottom: -0.2em;
}
.square.individual:before {
    transition-delay: 0.6s;
}
.square:after {
    right: 0;
    top: -0.2em;
}
.square.individual:after {
    transition-delay: 0.2s;
}
.square a:before {
    left: 0;
    transition: 0.25s all ease;
}
.square a:after {
    right: 0;
    transition: 0.25s all ease;
}
.square.individual a:after {
    transition: 0.25s all ease 0.4s;
}
.square:hover:before,
.square:hover:after {
    height: calc(100% + 0.4em);
}
.square:hover a:before,
.square:hover a:after {
    width: 100%;
}

 

 

 

未经允许不得转载:乔越博客 » CSS3按钮各种线性动画环绕线动画

赞 (1) 打赏

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. 123alert(1111)回复

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏