<button class="button--wipe">Wipe left to right</button>
<button class="button--wipe button--wipe-vertical">Wipe top to bottom</button>
/**
* Button wipe with NO pseudo-elements
*/
/* button--wipe */
.button--wipe {
--bg-color: thistle;
--bg-color-hover: darkorange;
--bg-size: 0% 100%;
--duration: 300ms;
--easing: cubic-bezier(0.165, 0.840, 0.440, 1);
--padding-x: 1.5rem;
--padding-y: 1rem;
--wipe-dir: 90deg;
background-color: var(--bg-color);
background-image: linear-gradient(var(--wipe-dir), var(--bg-color-hover), var(--bg-color-hover));
background-repeat: no-repeat;
background-size: var(--bg-size);
color: black;
display: inline-block;
padding: var(--padding-y) var(--padding-x);
transition: background-size var(--duration) var(--easing);
}
.button--wipe:hover {
--bg-size: 100% 100%;
background-image: linear-gradient(var(--wipe-dir), var(--bg-color-hover), var(--bg-color-hover));
background-size: var(--bg-size);
}
/* button--wipe-vertical */
.button--wipe-vertical {
--bg-size: 100% 0%;
--wipe-dir: 180deg;
}
/**
* demo styles
*/
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: ghostwhite;
font-family: system-ui, system, sans-serif;
padding: 1rem;
}
button {
border: 0;
cursor: pointer;
font-family: system-ui, system, sans-serif;
font-weight: 600;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.