Skip to content

Instantly share code, notes, and snippets.

@Kcko

Kcko/button.css

Last active Dec 22, 2020
Embed
What would you like to do?
.button
{
position: relative;
z-index: 1;
overflow: hidden;
width: 200px;
height: 50px;
background: transparent;
border: 2px solid red;
border-radius: 0.325rem;
color: #fff;
font-size: 18px;
font-weight: 600;
transition: color .35s;
display: inline-block;
}
.button::after
{
content: "";
position: absolute;
z-index: 2;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background: red;
transition: transform .25s;
transform: scale(0, 1);
transform-origin: 50% 0%; # thats do the trick!
}
.button-text
{
position: relative;
z-index: 2;
color: red;
transition: color 0.35s;
}
.button:hover::after
{
transform: scale(1, 1);
}
<!-- https://jsbin.com/bowaxu/1/edit?html,css,output -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<a href="" class="button"><span class="button-text"></span></a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment