I'm building a website and the menu is up there, working fine.
However, for it to be more user-friendly, I thought maybe I could put the login/logout button all the way to the right.
But there's a problem since I'm using Zend Framework, I can't assign a class to the <li> element, only to the <a> element.
As a normal working process, this list item is already always the last one, which makes it much easier to work with! I guess I could go ahead with some jQuery to detect this element and work around my problem, but then I discovered the "last-child" selector.
In my CSS file, I just added this:
#navigation UL LI:last-child {
float: right;
}
The "last-child" selector will make the last element of the selected type (here, li) follow the defined styles.
And there we have it. Instead of the element always being last but anywhere on the menu tabs, now the login (or logout) tab is always all the way to the far right!
Note that this is not supported in all browsers, but it simply won't change anything in others. Just a little bonus for those users who can keep their stuff updated!
Hello,
ReplyDeleteDoes it work on IE6 ? :D
No, only IE9 xD
ReplyDelete