Reputation: 17467
I have black text that I would like to make yellow on hover.
However I would like to transition to make the text fill the colour from the bottom to the top of the text.
Is possible with pure css?
Upvotes: 1
Views: 2341
Reputation: 39392
data-*
attribute.::before
or ::after
pseudo element.0
on hover..text {
display: inline-block;
vertical-align: top;
position: relative;
line-height: 40px;
font-size: 30px;
cursor: pointer;
margin: 20px;
color: gold;
}
.text:before {
transition: height 0.5s ease;
content: attr(data-text);
position: absolute;
overflow: hidden;
height: 40px;
color: black;
left: 0;
top: 0;
}
.text:hover:before {
height: 0;
}
<div class="text" data-text="Some text here">Some text here</div>
Upvotes: 5