I am making a toolbar menu of three elements, which should have the same styling except for different background images that serve as icons.
HTML:
<div id="menu-handheld">
<a href="page.php?stuff=things" id="menu-handheld-tab-start">Start</a>
<a href="page.php?stuff=things" id="menu-handheld-tab-trends">Trends</a>
<a href="page.php?stuff=things" id="menu-handheld-tab-recent">Recent</a>
</div>
CSS:
#menu-handheld {
position: fixed;
width: 100%;
height: 3.8rem;
bottom: 0;
z-index: 100;
}
#menu-handheld-tab-start { background: rgb(0, 51, 51) no-repeat 50% 0.5rem/2rem url(img/icons/start.svg) }
#menu-handheld-tab-trends { background: rgb(0, 51, 51) no-repeat 50% 0.5rem/2rem url(img/icons/trends.svg) }
#menu-handheld-tab-recent { background: rgb(0, 51, 51) no-repeat 50% 0.5rem/2rem url(img/icons/recent.svg) }
[id|=menu-handheld-tab], [id|=menu-handheld-tab]:visited { /* common CSS */
display: block;
float: left;
box-sizing: border-box;
width: 33.33333%;
height: 100%;
padding-top: 2.5rem;
color: rgb(102, 153, 153);
font-size: 1rem;
font-family: treme-extra-light;
text-decoration: none;
text-align: center;
transition: background 0.3s ease;
}
[id|=menu-handheld-tab]:active, [id|=menu-handheld-tab]:hover {
background-color: rgb(102, 153, 153); /* this does not work */
color: rgb(0, 51, 51); /* this works fine */
}
As I commented in the code, the :hover/:active transition works fine on the text color, but not at all on the background-color. I believe this is an issue with the fully written out background properties I am using for each element separately, because I had the same problem when I tried to define the background property in the common CSS and only use background-image in the separate selectors.
What am I doing wrong here? Why does background-color, or background-anything for that matter, fail to overwrite the background property? I realize I may fix my problem by defining another set of three #menu-handheld-tab-stuff {} selectors and writing out a new full background definition, but that's not a solution.