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

  • SEARCH
  • Home
  • 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 9019513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:47:47+00:00 2026-06-16T04:47:47+00:00

How can I set a custom background color for e.g., the active item in

  • 0

How can I set a custom background color for e.g., the active item in the dropdown when using Bootstrap’s “typeahead” autocomplete?

A minor problem, but one that has been frustrating me for a couple of hours!

I’m using Twitter Bootstrap in a Rails 3.2 app, via the bootstrap-sass gem.

I assumed this was controlled by the dropdown menu styling, but

$dropdownLinkBackgroundHover: $customColor;

does not work.

I also tried a more specific approach

.typeahead .active > a, .typeahead .active > a:hover { background-color: $customColor; }

but this also does not appear to work.

What am I overlooking? Or should my fixes be working, and the issue lies elsewhere?

  • 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-16T04:47:48+00:00Added an answer on June 16, 2026 at 4:47 am

    First, it would appear that the :hover state is not used for the typeahead, but only the .active one, as seen in the javascript plugin (2.2.2 on github)

    So if you change the color variable it has to be the $dropdownLinkColorActive variable (that will override all the dropdowns, whether there are from typeahead or not).


    Secondly the little trick is that the background is not only set by the background-color, which is a fallback, but by the background-image as seen from the Less call to the Less mixin – code shown at the bottom.

    And if you want to set a new color only to the dropdowns of typeahead, you have to override the color with the .typeahead +.dropdown-menu .active > a selector (at least for now).

    Live demo (jsfiddle)

    Here is what you have to override :

    .typeahead + .dropdown-menu .active > a,
    .typeahead + .dropdown-menu .active > a:hover {
        color: #ffffff;
        background-color: #FF77FF;
        background-image: -moz-linear-gradient(top, #FF77FF, #FF44FF);
        background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#FF77FF), to(#FF44FF));
        background-image: -webkit-linear-gradient(top, #FF77FF, #FF44FF);
        background-image: -o-linear-gradient(top, #FF77FF, #FF44FF);
        background-image: linear-gradient(to bottom, #FF77FF, #FF44FF);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF77FF', endColorstr='#FF44FF', GradientType=0);
    }
    

    This is based on the original less version of Twitter Bootstrap 2.2.2, but it most surely is the same for the sass ported version.

    For posterity, here is the less code referenced (version 2.2.2) :

    /* called in .dropdown-menu .active > a */
    #gradient > .vertical(@dropdownLinkBackgroundActive, darken(@dropdownLinkBackgroundActive, 5%));
    
    /* mixin */
    #gradient {
      .vertical(@startColor: #555, @endColor: #333) {
        background-color: mix(@startColor, @endColor, 60%);
        background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
        background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
        background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
        background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
        background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
        background-repeat: repeat-x;
        filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PreferenceActivity, how can I set a custom title bar? Not only
I have set a custom gradient color background for my nav bar. I want
I need to set a custom color to a list item based on a
Possible Duplicate: How do I programmatically set the background color gradient on a Custom
I have a custom listview by using an adapter which has alternate background color.
How can I set a custom filter in my code to ignore accents and
In Linux, can one set a custom icon for a folder/directory as it appears
I just can't figure it out how to set custom validator messages in Zend_Form
In a custom view, is there a way I can set the center of
I have a custom UITabvleViewCell that has a UIImageView in it. I can set

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.