I've got a tabbed menu that looks something like this:
The html for it is simple:
<div id="menuContainer">
<ul id="menu" class="undecorated ">
<li id="menuHome"><%= Html.ActionLink<HomeController>(c=>c.Index(), "Home") %> </li>
<li id="menuAbout"><%= Html.ActionLink<UsergroupController>(c=>c.About(), "About") %> </li>
<li id="menuArchives"><%= Html.ActionLink<UsergroupController>(c=>c.Archives(), "Archives") %> </li>
<li id="menuLinks"><%= Html.ActionLink<UsergroupController>(c=>c.Links(), "Links") %> </li>
</ul>
<div id="menuBar" class="container"> </div>
</div>
And the JQuery:
$(function() {
$('.container').corner();
$('ul#menu li').corner('30px top');
});
and on each page something like:
$(function() {
$('#menuHome').addClass('current')
})
I would like to indicate the "current" tab with a drop shadow behind it. I am thinking I would do this by
- Create a shadow 'li' with $('.current').after('  ')
- Use CSS to set the shadow color and round the top right corner with jquery
- Shift it over with CSS position: relative; top: 5px; left: -5px;
The problem that I am having is that the shadow appears on top of the element to the left. Setting its z-index low makes it disappear altogether for some reason. How do I make it appear behind the previous list-item?
Alternatively, what's a better way to do this?
I think you might want to consider using the CSS box-shadow technique. Mozilla and Webkit have implemented it, and box-shadow is in the CSS3 specs so someday it should be widely adopted. There is also a box-shadow filter for IE, but I don't know if it displays a very good look shadow. However, if you used this technique, it would be much more efficient. Although it wouldn't work in EVERY browser, it would give a similar effect for most of your users.
Here's a link to some more details about it: http://www.css3.info/preview/box-shadow/
Here's some information on IE filters (very under-utilized):http://www.ssi-developer.net/css/visual-filters.shtml
If you are looking for a shadow around the entire image, consider using the IE glow filter instead of the dropshadow.
Here's some sample CSS to work with if you want to try this technique.
Apply this style to the current tab (not shadow):
And this to the shadow
I messed around with this and ended up adding the following (note: I set Archives to current to see it better)
CSS
jQuery
You can mess around with the variables a bit to get the shadow where you want it :P
Edit: It doesn't appear to work in IE, but then a few other parts are off as well... I'll look at it some more Edit2: Ok, I got it to work in IE, but it's obvious now that the corners are made by a bunch of div's and the background doesn't match up - it looks fine in FF and Chrome
I suspect the way
.corner();
works is by drawing hundreds of 1px divs that are the same color as what's behind them. At the very least, the shadow needs to be.corner()
ed first. If this still doesn't work, then in fact.corner()
just takes the background color (white).