Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:43:18+00:00 2026-06-13T18:43:18+00:00

I have a navigation bar, where the buttons have a hover state but also

  • 0

I have a navigation bar, where the buttons have a hover state but also need to be “active” on their respective page. Since this navigation bar is part of an include, I decided to do the active state via a class on the body tag, as in .dashboard .dashboard-button. So I have the hover and this.

I was trying to figure out the most streamlined way to do this with Sass/Compass. I created a couple of mixins:

@mixin nav-button-on($icon) {
    background-color: #2f3684; // Old browsers
    @include filter-gradient($offwhite, #E5E5E5, vertical); // IE6-9
    @include background-image(url('../images/'+$icon+'-on.png'),linear-gradient(top, $offwhite 0%, #E5E5E5 100%));
    border-bottom: $borderbottom solid #F31A35;
    a { color: $red;}
}
@mixin nav-button($icon){
    background-color: #fff; // Old browsers
    @include filter-gradient(#fff, #fff, vertical); // IE6-9
    @include background-image(url('../images/'+$icon+'.png'),linear-gradient(top, #fff 0%, #fff 100%));
}

And then in the LI where the buttons are defined, I have

 li {
 &.dashboard { 
            @include nav-button('dashboard'); 
        }
        .dashboard &.dashboard { 
            @include nav-button-on('dashboard'); 
            &:hover {
                 @include nav-button-on('dashboard'); 
            }
        }
}

HTML:

<body class="dashboard">
<div id="nav">
    <ul>
    <li class="first dashboard"><a href="/index.php">Dashboard</a></li>
    <li class="challenges"><a href="/challenges.php">Challenges &amp; Teams</a></li>
    <li class="goals"><a href="/goals.php">Goals</a></li>
    <li class="activity"><a href="/my-activity.php">My Activity</a></li>
    <li class="destinations"><a href="/destinations.php">Destinations</a></li>
    <li class="fitness last"><a href="/fitness-resources.php">Fitness Resources</a></li>
</ul>
</div>

This seems a bit convoluted, I was wondering if anyone had any advice to streamline this at all.

NOTE: I had to add the white-to-white gradient, since when hovering over a solid-color background with the gradient hover state caused a flash.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:43:20+00:00Added an answer on June 13, 2026 at 6:43 pm

    There are a number of things to improve here:

    1. Are you really dealing with that hierarchy of dashboard classes? For example, you’re currently compiling to:

      li.dashboard {
          ...
      }
      li .dashboard li.dashboard {
          ...
      }
      

      This seems wrong or at least poorly structured. Perhaps you could simplify things here.

    2. Assuming you need this for each of your nav <li> elements, DRY it up with an iterated mixin:

      li {
          @each $item in dashboard, challenges, goals, activity, destinations, fitness {
              &.#{$item} { 
                  @include nav-button($item); 
              }
              .#{$item} &.#{$item} { 
                  @include nav-button-on($item); 
                  &:hover {
                      @include nav-button-on($item); 
                  }
              }
          }
      }
      
    3. But #2 is not actually the best way. Use placeholders rather than mixins for this kind of stuff, or combine the two. I’d do something like this:

          %nav-button {
              background-color: #fff; // Old browsers
              @include filter-gradient(#fff, #fff, vertical); // IE6-9
          }
      
          %nav-button-on {
              background-color: #2f3684; // Old browsers
              @include filter-gradient($offwhite, #E5E5E5, vertical); // IE6-9
              border-bottom: $borderbottom solid #F31A35;
              a { color: $red;}
          }
      
          @mixin li-image($icon) {
              @include background-image(url('../images/'+$icon+'.png'),linear-gradient(top, #fff 0%, #fff 100%));
          }
      
          @mixin li-image-on($icon) {
              @include background-image(url('../images/'+$icon+'-on.png'),linear-gradient(top, $offwhite 0%, #E5E5E5 100%));
          }
      
          @each $item in dashboard, challenges, goals, activity, destinations, fitness {
              body.#{$item} li, li.#{$item}:hover {
                  @extend %nav-button-on;
                  @include li-image-on($item);
              }
              li.#{$item} {
                  @extend %nav-button;
                  @include li-image($item);
              }
          }
      

    Compare the outputs and maintainability of these and I think you’ll find this quite a bit more streamlined!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom buttons in the nav bar, I want to toggle their state
I have a navigation bar that tells the user which page is selected by
I have a navigation bar and I need to always keep the current one
Imagine I have a navigation bar in my page header, with a number of
I have an app with a navigation bar consisting of 2 bar buttons. I
I have a navigation bar that contains multiple buttons, including a back button, edit
I'l like for one of the buttons in my navigation bar to have a
I have implemented this code in appDelegate in order to costumize navigation bar back
I have a navigation bar with three buttons on the right (arrows for navigation
I am currently adding a navigation bar to a web page. But I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.