SVG button example code based on CSS animation

SVG button example code based on CSS animation

The specific code is as follows:

<a href="#">
    <svg>
        <rect></rect>
    Button
</a>
body {
    margin: 0;
    padding: 0;
    background: #000;
}
a {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    font-family: sans-serif;
    text-transform:uppercase;
    font-size: 24px;
    letter-spacing: 4px;
    color: #fff;
    text-decoration: none;
}
a svg,
a svg rect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    fill: transparent;
}
a {
    svg rect {
        stroke: #00e2ff;
        stroke-width: 4;
        transition: 2s;
        stroke-dasharray: 60 200;
        stroke-dashoffset: 320;
    }
    &:hover {
        svg rect {
            stroke: #ff0;
            stroke-dasharray: 200 60;
            stroke-dashoffset: 0;
        }
    }
}

Summarize

The above is the SVG button based on CSS animation introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  Specific use of MySQL segmentation function substring()

>>:  JavaScript to achieve lottery effect

Recommend

harborRestart operation after modifying the configuration file

I won't say much nonsense, let's just loo...

React nested component construction order

Table of contents In the React official website, ...

VMware, nmap, burpsuite installation tutorial

Table of contents VMware BurpSuite 1. Virtual mac...

JavaScript Array Detailed Summary

Table of contents 1. Array Induction 1. Split a s...

Detailed explanation of the application of CSS Sprite

CSS Sprite, also known as CSS Sprite, is an image...

Detailed explanation of mysql scheduled tasks (event events)

1. Brief introduction of the event An event is a ...

Implementation of built-in modules and custom modules in Node.js

1. Commonjs Commonjs is a custom module in nodejs...

How to modify the length limit of group_concat in Mysql

In MySQL, there is a function called "group_...

A practical record of an accident caused by MySQL startup

Table of contents background How to determine whe...

How to view the database installation path in MySQL

We can view the installation path of mysql throug...

How to view files in Docker image

How to view files in a docker image 1. If it is a...

A record of pitfalls in JS regular matching

I recently discovered a pitfall in regular expres...