+ 1

CSS: :checked selector affect multiple elements

Hi guys, I'm trying to build a mobile navbar using the :checked selector of a hidden check box to reveal the navigation. I would like to make it so that when the it is checked (navigation is showing) for the icon to change, perhaps rotate or whatever. on line 184 of CSS: #toggle:checked + #ham-list-items { -webkit-transform: translateX(0px); } many thanks in advanced! excuse the sloppy code, I just started with web dev I'll attach the full code https://code.sololearn.com/W2vCWG8SsHDI/?ref=app https

11th Apr 2018, 2:37 AM
064XP
064XP - avatar
8 Respostas
+ 1
ahhh, so you used the + for the button because it is a direct decendant of the input, and de ~ so it would target what was below. Is that correct?
12th Apr 2018, 2:20 PM
064XP
064XP - avatar
0
Niush sitaula yes, it works but I would like to be able to modify (for example rotate) the hamburger button while the navigation is showing and go back to its original orientation once navigation is hidden again
11th Apr 2018, 4:34 AM
064XP
064XP - avatar
0
Hi 064XP Here is sample working code. You need to target the sibling css selectors correctly https://code.sololearn.com/Wij0MJ5wy0l3/#html
11th Apr 2018, 12:41 PM
Mike Choy
Mike Choy - avatar
0
Mike Choy Cool! Thank you. So can I only have one item using the + selector? Or what exactly was the issue?
11th Apr 2018, 10:23 PM
064XP
064XP - avatar
0
So your toggle : checked is targeting sibling selectors using the + pseudo selector. The + only refers to the direct descendant. I changed to using ~ pseudo selector to target any sibling selector. Had to add some animations for the hamburger menu also.
12th Apr 2018, 5:05 AM
Mike Choy
Mike Choy - avatar
0
yep
12th Apr 2018, 3:00 PM
Mike Choy
Mike Choy - avatar
0
cool! Thanks Mike
12th Apr 2018, 3:06 PM
064XP
064XP - avatar
- 1
?
1st May 2018, 9:41 AM
Abror