- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi,
I am designing a navigation bar and when the user clicks on a link, that link should change red so they know which page their on. However, only the a tag changes colour, with the li tags remaining white, creating “spaces” in between each link and therefore looking very untidy. How do I resolve this?
Thanks!
See the Pen Nav bar troubles by Anon Student (@cssrookie) on CodePen.
The “space” between the li
elements is a margin defined here;
.grid-x > .cell {
margin: 0 0.5rem;
}
Is that what you mean?
Yes thank you! It works now! Do I just have to apply the 0.5rem to all of the other content manually now? Or is there a way of keeping that and making the navigation bar different?
Thanks a lot!!!
You’re can increase the specificity to include nav
and change the setting lower down the cascade;
.grid-x > .cell {
margin: 0 0.5rem;
}
nav .grid-x > .cell {
margin: 0;
}
Or in case you have other nav
elements that would be affected, give the nav
a class and increase specificity that way.