Navbar toggler without has or JS

I have this navbar toggler was working on today. Is there a way to make it without :has() or JS without compromising anything else? https://codepen.io/myntsu/pen/vYrOjVo
Myndi
CodePen
vYrOjVo
...
1 Reply
MarkBoots
MarkBoots2y ago
yea, you can use the sibling ~ selector change .navbar:has(#checkbox[name="checkbox"]:checked) .navbar-items { } to #checkbox[name="checkbox"]:checked ~ .navbar-items { } note: you already have the right html structure, but be sure you keep the .navbar-items after the input. The sibling selector can only look at the next elements, not previous ones you can make it a bit cleaner by leaving away the attribute selector. The id is already specific enough #checkbox:checked ~ .navbar-items { }