Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Active link needs to be all one colour, but does not change (nav bar)

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #270139
    cssrookie97
    Participant

    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.

    https://static.codepen.io/assets/embed/ei.js

    #270140
    Beverleyh
    Participant

    The “space” between the li elements is a margin defined here;

    .grid-x > .cell {
      margin: 0 0.5rem;
    }
    

    Is that what you mean?

    #270141
    cssrookie97
    Participant

    @Beverleyh

    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!!!

    #270147
    Beverleyh
    Participant

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.