Forum Moderators: not2easy

Message Too Old, No Replies

How do you create a Rollover button with identifying text off to the s

         

The_Mexican

9:46 pm on Nov 11, 2008 (gmt 0)

10+ Year Member



Hi-

So this is my website <snip> I created using HTML. I'm recreating it using only CSS. When you roll your mouse over the navigation each button box fills with a color; and the title off to the right. Also, when you click on the button it stays highlighted until you click a different button. So how do I do this in CSS?

Thanks much.

body,td,th {
font-family: "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
font-size: medium;
color: #FFFFCC;
}
#wrapper {
background-color: #333333;
width: 640px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
body {
background-color: #000000;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#contentNavigation {
padding:7px;
background-image: url(slices1/images/page1_navplaceholder.jpg);
}
#navigation a {
font-size: 90%;
text-decoration: none;
}
#navigation a:hover {
background:url(slices1/images/navbutton_up.gif);
text-decoration: none;
}
#navigation ul {
margin: 0px;
padding: 0px;
}
#navigation li {
list-style-type: none;
display: inline;
margin-right: 5px;
margin-left: 5px;
}
#rightgreyBox {
float: right;
padding: 0px;
margin-top: -246px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
text-align: right;
}
#leftgreyBox {
margin: 0px;
text-align: left;
}
#myPicture {
margin: 0px;
text-align: left;
}
-->
</style>
</head>

<body>
<div id="wrapper">

<div id="top"><img src="slices1/images/page1_header.jpg" alt="Roy Header" width="640" height="60" /></div>

<div id="Body Pic"><img src="slices1/images/page1_graphic.jpg" alt="Man's back" /></div>

<div id="navigation">
<div id="contentNavigation">
<ul>
<li><a href="index2.html"><img src="slices1/images/navbutton_up.gif" /></a></li>
<li><a href="page2.html"><img src="slices1/images/navbutton_up.gif" /></a></li>
<li><a href="page3.html"><img src="slices1/images/navbutton_up.gif" /></a></li>
<li><a href="page4.html"><img src="slices1/images/navbutton_up.gif" /></a></li>
<li><a href="page4.html">Graphic title goes here.</a></li>
</ul>
</div>
</div>


<div id="myPicture"><img src="slices1/images/pic_roy.jpg" alt="Roy" width="146" height="123" /></div>

<div id="leftgreyBox"><img src="slices1/images/page1_btmleft.jpg" alt="leftgreybox" width="146" height="123" /></div>

<div id="rightgreyBox"><img src="slices1/images/page1_btmright.jpg" alt="rightgreybox" width="494" height="246" /></div>
</div>

[edited by: swa66 at 8:39 am (utc) on Nov. 12, 2008]
[edit reason] No personal URLs please, see forum charter [/edit]

webfoo

2:56 pm on Nov 15, 2008 (gmt 0)

10+ Year Member



Welcome to WebmasterWorld, The Mexican!

It seems that what you are trying to do requires JavaScript. Here's what I would do. I'd have a CSS class for each of the following:

.normal { // style for the regular button when nothing is happening to it
}
.over { // style for the button when the mouse is over it
}
.clicked { // style for the button when it has been clicked
}

The script would have to change the div from .normal to .over upon mouseover, and back to .normal on mouseout. Then, it would have to change the div to .clicked when it is clicked. Also, when one div is clicked, you probably want it to "unclick" the rest of the clicked divs back to .normal

This is how I would do it. The other way you could do it would be to have different images for each button status. Have the script switch the src of the image instead of the class.

If you need help writing the Javascript, please ask! The JavaScript [webmasterworld.com] forum is a helpful place to get started. I also reccomend W3Schools JavaScript tutorial.

I hope this helped!

-webfoo

The_Mexican

11:37 pm on Nov 15, 2008 (gmt 0)

10+ Year Member



It helps a lot...
I had a feeling I was going to have to use Javascript. Just when I thought I was making progress in Mozilla Firefox, IE doesn't support the rollover effect.

Thank you so much for your help.

swa66

1:18 am on Nov 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE7.js can give IE6 the same capabilities as IE7 and frees you having to write javascript. Still what you seek feels to be beyond what CSS will give you.