I have 4 "lines" moving when button is hovered. https://codepen.io/aphroditef/pen/yLQvxNy
I would like to have this effect https://codepen.io/aphroditef/pen/GRwQXJB with 4 lines, not just the three of them . Any advice?
I tried these
.buttonY button {
background-color: transparent;
border: none;
position: relative;
width: 400px;
height: 120px;
text-transform: uppercase;
line-height: 120px;
text-align: center;
color: #4e1414;
font-size: 45px;
letter-spacing: 15px;
overflow:hidden;
}
.buttonY button:after{
content:'';
position: absolute;
top: 100%;
right: -100%;
width: 100%;
height: 4px;
background-color: #4e1414;
transition: all 0.5s;
}
.buttonY button:hover:after{
right:0;
}
and I expected ‘button:after’ behave like ‘button:before’ .
2
Answers
The problem is that the after pseudo element is being placed at top: 100%. This puts its top at, well, 100% down so it’s just outside the element.
Instead you can use bottom to ensure it’s just inside the element.
Note: the modern standard for indicating pseudo elements, as opposed to pseudo classes, is to use a double colon (::).
If you want to consider an easier idea here is one with less of code:
Related article for mode details: https://css-tricks.com/cool-hover-effects-using-background-properties/