- This topic is empty.
-
AuthorPosts
-
October 29, 2018 at 12:50 pm #278211lucibatParticipant
When I hover over a tag, its siblings psuedo element changes its width in more than the specified tag that Im currently hovering over. How do I fix this?
Basically theres a little red block
an:before
that I want to expand when I hover over its parents siblingqu
. And it does, but if I hover over ONEqu
tag, every tag beneath it also activates the psuedo element.P.S The
an
tag must remain the parent.<qu> Maecenas interdum eleifend massa eget tincidunt.</qu> <an>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</an> <qu> Maecenas interdum eleifend massa eget tincidunt.</qu> <an>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</an>
qu{ margin-left:4%; margin-right:4%; display:block; font-family:open sans; letter-spacing:1px; font-weight:600; line-height:18pt; text-transform:uppercase; color:black; font-style: italic; margin-bottom:20px; position:relative; } an{ font-family:source sans pro; font-size:18pt; letter-spacing:0.1pt; line-height:28pt; font-weight:100; position:relative; color:#565656; display:block; margin-bottom:70px; } an:before{ content: ""; width:20px; background:red; height:10px; position: absolute; } qu:hover ~ an:before{ width:100px; }
You can see it in motion here: https://codepen.io/kitglitch/pen/rqbPOq
October 29, 2018 at 3:06 pm #278216BeverleyhParticipantI think you’re looking for the adjacent sibling selector https://css-tricks.com/almanac/selectors/a/adjacent-sibling/
Also, why are you inventing your own
qu
andan
elements and not using standard HTML elements?October 29, 2018 at 4:59 pm #278229lucibatParticipantThankyou. Id rather use my own instead of using the italic/bold tags because i want them to maintain their individuality if i were to use them later on
October 30, 2018 at 12:19 am #278236Paulie_DMemberYou should be aware that custom elements may not be recognised by browsers unless you know exactly how to enable them.
It’s not as simple as just using special names.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.