In my web application, I have implemented a 'tab toolbar' with 3 tabs. When a user clicks on a tab, the page displays different data based on which tab is selected.
To visually indicate to the user which tab they have clicked on, I dynamically change its CSS class upon selection.
The selected tab undergoes the following changes: (1) it gets a yellowish background with a gradient effect; (2) the font size increases; (3) the width and height of the tab increase by approximately 6 pixels each.
Although this functionality works smoothly in Firefox, there are issues in IE 10.0.9200 specifically related to the background color and gradient of the selected tab. For example, when selecting tab #3 for the first time, everything appears as intended - the yellow gradient background along with the larger font and increased dimensions are applied.
However, in IE, there seems to be a problem where part of the 'selected' CSS class is not retained if a different tab is selected and then tab #3 is clicked again. Subsequent selections of tab #3 only show the font size and dimensions changes, but the colored background gradient is missing.
A simple solution is to reload the page in IE, after which the colored background gradient magically reappears.
Below is the CSS code for the 'selected' class:
.selectedTabClass{
-moz-box-shadow:inset 0px 1px 0px 0px #fff6af;
-webkit-box-shadow:inset 0px 1px 0px 0px #fff6af;
box-shadow:inset 0px 1px 0px 0px #fff6af;
background:-webkit-gradient( linear, left top, left bottom,
color-stop(0.05, #ffec64), color-stop(1, #ffab23) );
background:-moz-linear-gradient( center top, #ffec64 5%, #ffab23 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64',
endColorstr='#ffab23');
background-color:#ffec64;
...
}
.selectedTabClass:hover {
background:-webkit-gradient( linear, left top, left bottom,
color-stop(0.05, #ffab23), color-stop(1, #ffec64) );
background:-moz-linear-gradient( center top, #ffab23 5%, #ffec64 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffab23',
endColorstr='#ffec64');
background-color:#ffab23;
}
.selectedTabClass:active {
position:relative;
top:1px;
}
This is how the HTML looks like:
<label class="selectedTabClass" id="tab3"
onclick="handleTabSelect(3, this)">this is Tab #3</label>
And here is the corresponding Javascript function:
function handleTabSelect(whichTab, thisOne)
{
document.getElementById(whichTab).className = "selectedTabClass";
}
I am looking for a way to ensure consistent behavior across all browsers, including IE. Any suggestions on how to achieve this would be greatly appreciated.