Forum Moderators: not2easy

Message Too Old, No Replies

Simple css question

         

Rightz

5:28 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



I am trying to create a menu with roll over buttons/tabs. Below is the code I am using. I have 2 buttons - red and white. The white one I want to show automatically when a person is on that page. For example when on template.html the image will be white. Currently the button is only showing the white image when you roll over it.

How can I get the white image to stay when it is on the selected page?

css:

<style type="text/css">

#menu {
height: 30px;
margin: 0em 0; padding:0 1em;
}

div.outer {
float: left;
width: 110px; height: 30px;
margin: 0 3px 0 0;
background: url( 'but1.gif' ) 0 -50px no-repeat;
}

div.outer a {
display: block;
margin: 0; padding:0;
width:100%; height:100%;
overflow:hidden;
font: bold 13px/1 Georgia, serif;
color:#990000;
text-decoration: none;
background: url( 'but2.jpg' ) top left no-repeat;
}
div.outer span {
display: block;
margin:0; padding: 13px 0 0 15px;
}
div.outer a:hover
{
display: block;
margin: 0; padding:0;
width:100%; height:100%;
overflow:hidden;
font: bold 13px/1 Georgia, serif;
color:#990000;
text-decoration: bold;
background: url( 'but1.jpg' ) top left no-repeat;
}
div.outer a:active {
color: black;
background: url( 'but1.jpg' ) top left no-repeat;
}

</style>

html:

<td bgcolor=#990000><div id="menu">
<div class="outer"><a href="template.html#"><span>Home</span></a></div>
<div class="outer"><a href="buytickets.html"><span>Buy Tickets</span></a></div>
<div class="outer"><a href="#"><span>Third</span></a></div></div>
</td>

yodokame

6:39 pm on Apr 6, 2007 (gmt 0)

10+ Year Member


You should write a minimal case, getting rid of all the markup not relevant to your question. More people will try to help you, and (in my experience) in making a minimal case, half the time you end up figuring out the problem yourself.

londrum

9:52 pm on Apr 6, 2007 (gmt 0)

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



you'll have to apply individual IDs to each link, and also an individual ID to the body on each page.

for example, on the FOOTBALL page, you'd have something like this:

<body id="football-page">

<li><a href="blah" id="football">Football</a></li>
<li><a href="blah" id="rugby">Rugby</a></li>
<li><a href="blah" id="swimming">Swimming</a></li>

and in the CSS:

li{
background:red;
}
#football-page li#football{
background:white;
}

Rightz

6:48 pm on Apr 7, 2007 (gmt 0)

10+ Year Member



londrum - thats exactly the answer i was looking for! thanks

think i can probably figure that out now! cheers!

Xapti

10:46 pm on Apr 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you do this if your link menu is in an iframe? The method given does not appear to work.

[edited by: Xapti at 10:47 pm (utc) on April 7, 2007]

londrum

8:34 pm on Apr 8, 2007 (gmt 0)

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



you'll have to do it a bit different, because if it's in an iframe then it's a completely different page.

what i used to do when i had frames, is i changed the navframe to another one with a javascript redirect, called from the top of whatever content page was showing.
but that meant that i needed several different navframe pages, tailored to whatever the content page was. which kind of ruined the whole point of using frames.

you could do it a lot better with php though. do you know php?

Xapti

5:32 am on Apr 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes that would totally ruin the point of using frames. It would also introduce JS, which is not something I am willing to do unless it's for internet explorer.

The reason I sometimes use Iframe navigation is that I do not alwats have access to SSI. I certainly don't want to re-write 20 pages every time I want to add a link to a navbar either (but that's only one reason).

I'm fine and content with just not using this frivilous feature. Hell, both the the page title, and large header tell you where you are, if you don't notice those... yeah...
...And :visited links show what pages have been visited still, so it's not too bad.

SilverLining

10:57 am on Apr 20, 2007 (gmt 0)

10+ Year Member



How can this be done if one is using templates and so one's
<body id="channelName">
will always be the same?

In my case, one thing that is diffent on all pages is the function which is set (e.g. index.html?fx=contact). Can one make use of this function somehow in the CSS or will this require JavaScript?

It's not really viable to split all these pages into separate channels and as such giving each page an individual ID in the BODY tag, although that would (easily) solve the problem.

londrum

8:57 pm on Apr 20, 2007 (gmt 0)

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



if that 'fx' variable is indeed different on every page, then i suppose you could write it out as a class, in the body tag.
it would be better to use php for this, as it would work for everybody, but if you're stuck with javascript then you could do something like this, where the body tag would normally go:

<script>
document.write('<body id="whatever" class="'+fx+'">');
</script>

<noscript>
<body id="whatever">
</noscript>

you'd then use that class in the CSS.

it wouldn't work for people with javascript turned off, though. (they'd just see whatever is in the <noscript> bit.) so i wouldn't fancy using it myself. you'd be better off looking into php.

SilverLining

10:32 am on Apr 23, 2007 (gmt 0)

10+ Year Member



Thank you londrum. Will look at implementing this with Java.