/ Gists / Transform origin - Filled buttons
On gists

Transform origin - Filled buttons

CSS CSS trick

index.html Raw #

<!-- 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>

button.css Raw #

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