Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Proper CSS "Sliding Doors"

Proper CSS "Sliding Doors"
Thread Tools
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Jul 4, 2006, 07:19 PM
 
I just read the (old) CSS Sliding Doors article on A List Apart, and I'd like to use the idea to make growable tabs using background images, but the main bug they leave really bothers me. In their examples, there's a dead space to the left of the tab that's highlight-able, but isn't part of the link. I understand why it's there, but I'm not sure how to go about undoing it. Is there even a way to make tabs that don't have a dead spot? Any ideas would be greatly appreciated!
     
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Jul 4, 2006, 07:57 PM
 
I found my answer after some more searching! Instead of putting the left image in the "LI" tag and the right image in the "A" tag, create a "SPAN" inside the "A", and shift everything over: "A" gets the left image, and the "SPAN" gets the right image, and is thus inside the "A" tag and is clickable. Exactly what I wanted.

See some code
     
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Jul 25, 2006, 05:55 PM
 
Originally Posted by macgyvr64
I found my answer after some more searching! Instead of putting the left image in the "LI" tag and the right image in the "A" tag, create a "SPAN" inside the "A", and shift everything over: "A" gets the left image, and the "SPAN" gets the right image, and is thus inside the "A" tag and is clickable. Exactly what I wanted.

See some code
There are two ways you could do it without the spans.
First note that, if you read the part one of the initial article, it says you can switch the order, putting the left image on the anchor and the right on the list item IF you are using tabs without a transparent background, which you are doing, so that would be an easy fix. However, even if you want transparency, there's another way... do like that (i.e. left image in the anchor, right in the list item), and then give the anchor a left margin that's negative, effectively moving it outside the li, meaning that the right image won't show through it. give the anchor some left padding so that the text is centered when you're done.

Here's the CSS:
Code:
#navigation ul li a { background: url("tab-left.gif") no-repeat; color: #06C; padding: 5px 0 5px 10px; margin-left: -9px; text-decoration: none; } #navigation ul li { background: url("tab-right.gif") no-repeat 100% 0; padding: 5px 10px 5px 0px; }
I had to sacrifice left and right padding on the tabs being in ems, but I actually like it better fixed anyway, so...

also, you can kill the .last thing... just do like this:
Code:
#navigation ul li { display: inline; margin-left: 10px; } #navigation ul li + li { margin-left: 1.75em; }
The margin on the first li is to keep the set centered, and then every one after that gets extra to keep them separated. (I dunno if the + selector works right in stupid IE, but I'll let you test that)
     
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Jul 25, 2006, 11:26 PM
 
Thanks, I'll have to give that a try, as well!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:53 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2