views:

32

answers:

2

I'm building something similar to this - http://www.impressivewebs.com/demo-files/content-switcher/content-switcher.html

I wondered if anyone had any ideas as to how I can show the current panel in the navigation WITHOUT using JavaScript - pure CSS.

I'm fairly confidant it's not possible but I thought I'd ask anyway.

Just to clarify...
You'll notice that when you click a link on this page - http://www.impressivewebs.com/demo-files/content-switcher/content-switcher-javascript.html the link you just clicked on highlights to inform the user which panel they're looking at. That's what I want to do in CSS.

+4  A: 

It's possible, believe it or not, it's just really tricky. This should get you started: http://thinkvitamin.com/design/css/how-to-create-a-valid-non-javascript-lightbox/ The key bit is captured in this quote:

I'm sure you are all aware of linking to an an element on the same page with the use of the ID attribute and how it works. However, you may not have known that linking to an element that is hidden off the page causes the element to be "pulled" into view as opposed to the window jumping down to that element.

So basically, you'd put all of your slides off-page and then have the numbered links use anchors to pull those into view. Your use case should be a bit simpler than the one she's doing, since you don't have to dim out the rest of the page.

T.J. Crowder
@Sam: You could make the navigation part of the thing being pulled into view (and so the first panel would include the navigation with the first nav link blue; the second panel would include the navigation with the second nav link blue; etc.) Or position your nav links such that content within the panel being brought into view can point at them (rather than highlighting them). (And sorry, btw, I didn't realize at first that the thing you linked to *was* CSS-only.)
T.J. Crowder
(The comment above was replying to a comment from Sam that he's now deleted and folded into his question.)
T.J. Crowder
@T.J: Thanks, the panels are going to be created dynamically with an unlimited number of instances so it could be a bit heavy making lots of instances of the navigation. I'll give it a try though!
Sam
wow, that's an awesome solution. I don't even really get it yet, but I will. Never knew that was possible
Litso
@Litso: Yeah, it's incredible, isn't it? As I say, it all hinges on the behavior of browsers when you try to go to an anchor that's hidden off-page. Major kudos to the people who figured that out...
T.J. Crowder
A: 

What you need to do is to put what you need to slide inside a container with fixed size and "overflow" property set to hidden. Then, inside this container, you put your "slidable" contents inside a list of anchor elements with "display" set to block and size the same of the container. If, from a link on the page, you call one of the anchors in the list, the element with the correspondent anchor name will automgically show up.. simple as that.

Lucius