<h3 class="hover">Hover Me</h3>
.hover {
--b: 0.1em; /* the thickness of the line */
--c: #1095c1; /* the color */
color: #fff;
padding-block: var(--b);
background: linear-gradient(red 0 0) 0% var(--_p,0%)/var(--_p,0%) var(--b) no-repeat;
position: relative;
transition: .3s var(--_s,0s) linear,background-size .3s calc(.3s - var(--_s,0s));
}
.hover:before {
content:"";
position: absolute;
z-index: -1;
inset:-100% 0 0;
background: linear-gradient(var(--c) 50%,#000 0);
transition: .3s var(--_s,0s) linear;
}
.hover:hover {
--_p: 100%;
--_s: .3s;
}
.hover:hover:before {
transform:translateY(50%);
}
body {
height: 100vh;
margin: 0;
display: grid;
place-content: center;
}
h3 {
font-family: system-ui, sans-serif;
font-size: 3rem;
margin:0;
cursor: pointer;
padding: 0 .1em;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.