Skip to content

Instantly share code, notes, and snippets.

@Kcko
Last active December 22, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcko/601218030a8720eee0cc104b21d54835 to your computer and use it in GitHub Desktop.
Save Kcko/601218030a8720eee0cc104b21d54835 to your computer and use it in GitHub Desktop.
.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