Looking at the markup, we have list items with a class of nav-item. They contain a checkbox input. This one has a property of checked, so the page loads with this as the default selection. Then they have a corresponding label. On the end of the list, we have a login button.
Let's go ahead and start styling this. If we look at the CSS, I have commented out some styles here. It adds a background with a linear gradient, styling the nav just basically and then styling the nav items. Also, I have commented out the styling for the login button.
Let's go ahead and style these nav items with these radio buttons. We'll start by styling the label. I want to make these look like they're clickable, so I'm going to change the cursor to pointer. Let's add a three-pixel padding on the bottom, which we'll use for an underline in the selected state.
These radio buttons are in the way. They're nice for functionality, but not for design. On the radio button, I'm going to start by setting the pointer events to none. That'll make it so that if you click on it, nothing happens because we're actually then going to set the position to absolute to get it out of the layout and not mess up the layout further.
Then we're going to set the opacity to 0Then we're going to go ahead and set nav-item radio checked. We want to change the state of what happens when they're checked. I want to put a border on the bottom, which will act like an underline.
If you can see here, this didn't do anything. That's because the radio button's hidden. I'm going to use this + symbol, which is the sibling selector, so that when it's checked, the label should have an underline.
That's useful when the sibling is right after the initial selector, but if you have, like in this instance, where I've got a span in between, you can see that the pricing doesn't get its underline.
If I change this from a + symbol to a ~, what that'll give me is a general sibling selector. It doesn't have to be right after. There's a word of caution here, is that order is important.
I cannot select a sibling that comes before the first half of the selector. Doesn't work that way. Cascading styles only work in one direction. It has to be a sibling that follows after the initial element.
That's the sibling selector. If you use it correctly, there's not a ton of use cases for it, but when you really need it, it comes in very handy.