ads_header

Button Hover Border Effects CSS

Button Hover Border Effects CSS



Preview



Hello guys, this time I will make a button with "animation" on the border. By making an effect on a button when the pointer is highlighted or when clicked, it will look more vivid and make users more comfortable using it.





As usual, create a project folder, then create index.html and style.css files.

Open index.html and enter the following code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Button Border Animation</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <a href="#"><span></span>Hover Me</a>
</body>
</html>

open style.css and enter the following code

body
{
    margin: 0;
    padding: 0;
    background: #222;
}

a
{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 50px;
    background: #222;
    text-transform: uppercase;
    text-align: center;
    line-height: 50px;
    color: #fff;
    text-decoration: none;
    font-size: 20px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 4px;
}

a:before,
a:after,
span:before,
span:after
{
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff0;
    transition: 1s;
    mix-blend-mode: hue;

}
a:before
{
    top: -2px;
    left: -2px;
}
a:after
{
    top: -2px;
    right: -2px;
}
span:before
{
    bottom: -2px;
    left: -2px;
}
span:after
{
    bottom: -2px;
    right: -2px;
}

a:hover:before,
a:hover:after,
a:hover span:before,
a:hover span:after
{
    width: calc(180px /2);
    height: calc(50px /2);
}

Save all files and run index.html
Powered by Blogger.