Forum Moderators: not2easy

Message Too Old, No Replies

can i code into my style sheet to make a div show on selected pages?

         

Misery Kitty

11:14 am on Jul 17, 2008 (gmt 0)

10+ Year Member



Hi all.......... GREAT FORUM! wish i had of found it sooner

i have a problem..... i have a style sheet i have been working on ........ i have hit a brick wall.... i would like to set a style sheet (done) but i would like to tell a div to only show on allocated pages and not the rest. (my main problem is i cant access each page as its part of a subscription where they have the basics and i can access and code other parts......if that makes any sense lol )

sooo i was hoping ;) to put in some line of code that says this div is visible on [domain.com...] and manually put in each page it can show on (it needs to have each page listed in its full url or it wont work )

is it possible ?

i hope so or i have to do a work around and this site i am a subscriber of well....... lets just say their coding is from another planet... not well coded css and alot clashes that shouldn't or if i check areas to show something it just decides to show it elsewhere depending on its mood LMAO!

THANKS in ADVANCE and if its not possible i'd appreciate the honesty ;)

cheers
Kel

Fotiman

2:07 pm on Jul 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If each page contains a unique id value on the body element, then this is easy. For example:
<body id="page1">...</body>
or
<body id="page2">...</body>

If this is the case, then suppose your div has an id of "foo". You could do this to hide it on all pages except page1:


#foo {
display: none;
}
#page1 #foo {
display: block;
}

If there is NOT an ancestor with a unique id for each page, then I think you're going to have to look at a JavaScript solution.

Misery Kitty

12:05 am on Jul 18, 2008 (gmt 0)

10+ Year Member



yeh that was my first thought look for page ids and work with that but.... fun enough it doesn't have any ......

i thought of javascript too but .... i heard that with javascipt some browsers load the whole page then the javascript kicks in.. soooo i problem is i cant let this div show at all as it will really mess up the look of the pages its not meant to load in annnd... if someone has a slow connection it could be scary lol

its weird after lots of think i thought the way css is so flexible i thought for sure i'd find a simple code that says only show this div on:: http...../page1, http..../page4, http..../page7, etc and that would be that...

THANKS for the reply btw it is greatly appreciated!
cheers
kel

Fotiman

3:24 am on Jul 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So just make the div hidden by default (display: none) and use JavaScript to un-hide it!