Skip to content

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;
}

1 Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: