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?
First, it would appear that the
:hoverstate is not used for the typeahead, but only the.activeone, as seen in the javascript plugin (2.2.2 on github)So if you change the color variable it has to be the
$dropdownLinkColorActivevariable (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 thebackground-imageas 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 > aselector (at least for now).Live demo (jsfiddle)
Here is what you have to override :
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) :