I have created a CodePen with a working hover effect using :before
& :after
on li
link options. However, I am looking for a more efficient way to globally apply the position of these pseudo-elements without adding separate styles for each link option. Currently, the positioning is defined using absolute values for top and left, but I want the :before
& :after
to be in consistent positions relative to each li
.
This is what I have so far:
.myLi-1:hover:after {
top: 66px;
left: 284px;
position: absolute;
}
.myLi-1:hover:before {
top: -2px;
left: 284px;
position: absolute;
}
/* Repeated for List Item 2, 3, 4, 5 ... */
You can view the live version on CodePen for better understanding of the issue: