Before starting to preview code I want to get you a bit closer to the environment I'm currently in.. I'm trying to generate a menu with different tab-sections like "start, groups, help, etc.". Let's select just the centered tab-button, Groups.. which looks like this while hovered:
As soon as I'm entering one of the pseudo-elements, that I'm using to build those 45deg sides, the hover style for the parent div
switches off. But the pseudos are still visible:
Note: I'm not able to manipulate the html
markup. The only way I can achieve changes to the site is editing the css
.. Let's have a look at the code:
#header .nav-item {
width: 33.33%;
}
#header .nav-item:hover::before,
#header .nav-item:hover::after {
display: inline-block;
position: absolute;
height: 50px;
width: 50px;
}
#header .nav-item:hover::before {
margin-left: -25px;
background-image: -webkit-gradient(
linear, right top, left bottom,
color-stop(0.5, #111),
color-stop(0.5, #fff));
/* vendor specific gradients ... */
}
#header .nav-item:hover::after {
margin-left: -25px;
background-image: -webkit-gradient(
linear, right top, left bottom,
color-stop(0.5, #fff),
color-stop(0.5, #111));
/* vendor specific gradients ... */
}
Let's move over to...
My Question
Am I able to select the pseudo-elements state :hover
or is there any other usable way to achieve a clean transition, while moving through the items? So far I tried to select .nav-item::after:hover
, .nav-item::before:hover
, .nav-item:hover::after:hover
and .nav-item:hover::before:hover
...
Nothing worked, so I'm currently unable to force the pseudo-elements to do something while they're hovered..
Thanks in advance...
Edit - The solution
To force the pseudo elements not to stay visible while hovered, just put another element (e.g a
, 'span', ...
) above it using the z-index
.
Thank you @Merijn van Wouden ;)