Forum Moderators: not2easy

Message Too Old, No Replies

Show DIV based on ID

         

terrybarnes

9:26 pm on Feb 4, 2009 (gmt 0)

10+ Year Member



I have a menu that I'd like to include on every page of my site. I've included this in a header.php file that is used throughout the site. What I also have is subnav (horizontally directly under the main menu). I only actually have subnav for one section so I was wondering if there's a way to show that subnav DIV only when I'm in the relevant section and then hide for all other sections.

I would have thought having a display:none tag would be okay for the non display of the subnav but I don't know how I could show the DIV when I'm in the correct section.

Any help would be very much appreciated.

terrybarnes

10:27 am on Feb 5, 2009 (gmt 0)

10+ Year Member



I may have solved this problem - does this sound okay?

On the page I have this:

<div id="test">test</div>

and in the css I have

#test {visibility: hidden;}
body#about #test {visibility: visible;}

So that when the body id is "about" then the div will display. So this will only display when I'm in the about section and no other sections on the site.

simonuk

3:46 pm on Feb 5, 2009 (gmt 0)

10+ Year Member



Looks fine to me :-)