Reputation: 1657
I am implementing an "open the music player" button that will slide a music player into view. The sliding works fine in my actual project code, but the hover state is giving me problems.
Specific requirements:
before
pseudo-element.linear-gradient
) can't be coupled to the button itself. :(If I comment out the :before
styles, hover works fine. But when they're present they seem to interfere with the button's hover state, making it flicker and sometimes disappear entirely.
Thanks!
Upvotes: 0
Views: 241
Reputation: 2344
If the main element is a triangle and the pseudo-element is the background, the users may experience a flicker effect. Here is the related part in your code:
&:before {
content: "";
position: absolute;
display: block;
width: 100%;
height: 100%;
background: purple;
}
.open-player-btn {
margin: 15px;
border-style: solid;
border-width: 20px 0 20px 34px;
border-color: transparent transparent transparent orange;
.hover-opacity;
}
Try changing the element you put the pseudo-element on. Here is the revized code:
.open-player-btn {
width: 100%;
height: 100%;
background: purple;
.hover-opacity;
&:before {
content: "";
position: absolute;
display: block;
margin: 15px;
border-style: solid;
border-width: 20px 0 20px 34px;
border-color: transparent transparent transparent orange;
}
}
UPDATE:
If I didn't get it wrong, the arrow should face left on open state, but the gradient should stay the same. Changing the degrees on your CodePen as follows seems to do the trick.
&.open {
.open-player-btn-wrapper {
transform: rotate(90deg);
}
.open-player-btn {
transform: rotate(-90deg);
&:before { transform: rotate(180deg); }
}
}
Upvotes: 1