CSS Button Stroke

HTML CODE:

<!DOCTYPE html>
<html>
<head>
    <title>page</title>
     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="1.page.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
</head>
<body>

    <a href="">
        <svg>
            <rect></rect>
        </svg>
        Button
    </a>

</body>
</html>

CSS CODE:

body{
    margin: 0;
    padding: 0;
    background: #262626;
}
a{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 180px;
    height: 60px;
    text-align: center;
    line-height: 60px;
    font-family: sans-serif;
    text-transform: uppercase;
    font-size: 24px;
    letter-spacing: 2px;
    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: #fff;
    stroke-width: 4;
    transition: 3s;
    stroke-dasharray: 500,500;
    stroke-dashoffset: 0;
}
a:hover svg rect{
    stroke-dasharray: 100,500;
    stroke-dashoffset:315;
    stroke: #00bcd4;
}

One thought on “CSS Button Stroke

Add yours

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started