When working with Twitter Bootstrap, I encountered a challenge. The background-color
properties set for navigation items on the :focus
state were causing an issue for a specific navigation element that needed have its own styling.
Imagine a scenario where in a custom theme, the default background color of a navigation item is dark red. Upon hovering over it, the color changes to light red. However, due to Bootstrap's declaration for the :focus
state, clicking on the navigation item and moving the mouse away results in it turning light grey (as per the default Bootstrap theme). This behavior was something I wanted to remove.
The goal was to maintain the default behavior of the navigation item - dark red without the mouse hover and light red upon hovering. Unfortunately, attempts to achieve this were futile as the :focus
state seemed to override the :hover
state. Any declaration made for :focus
affected both mouse hover and mouse away interactions.
I experimented with background-color:transparent
and background-color:inherit
, but the underlying issue persisted. No matter what color was specified, it remained consistent regardless of whether the mouse was over the link or not. My ultimate objective was to ensure that the background color changed only when hovering over the link, even when it had focus.