Jump to content

Rollovers


xkyogre

Recommended Posts

You can do rollovers by javascript. No it doesn't require any prior knowledge. Just google it and find the code.

 

BUT, I heard CSS can do rollovers also, w/out javascript. - Which is even better because some ppl might have javascript disabled!! ;)

Link to comment
Share on other sites

Basically, the simple rollover solution (where the width and heights are the same) uses a different image for the specific a:hover, a:visited of an class or ID.

 

Example. Here http://www.regisresidential.com, I made 2 small images (2px wide by 20px high) - one red, one blue - to use for the links hover.

 

#navcontainer a, #navcontainer a:visited {

display: block;

padding: 0px 5px 4px 4px;

width:150px;

background: #800000 url(../images/roundlinks2.jpg) repeat-x;

border-bottom: 1px solid #FFF;

text-decoration:none;

color:#FFFFFF

}

 

#navcontainer a:hover, #navcontainer a:active {

background: #336699 url(../images/roundlinks.jpg) repeat-x;

}

 

Upon hover, the link background image changes from red to blue. Simple.

 

You use the same technique for text based links. Changing the text color, background color and border color on hover.

 

But be very careful. Whenever designating a:link elements in a style sheet, the proper order is absolutely required. You MUST list  a:link and a:visited BEFORE a:hover and a:active.

 

If you have initially designated all four link TAGS, then you MUST do the same for any modifications of links for a class or ID later.

 

example - if you designate the actual link TAG:

 

a {color:#0000FF} (or a:link)

a:visited {color:#000099}

a:hover {color:#FF0000}

a:active {color:#FFFFFF}

 

Then whenever you modify the link tags for a class or ID you must also re-designate the visited, hover and active:

 

example - class/id links:

 

.item a:link {color:#9999CC}

.item a:visited {color:#9900FF}

.item a:hover {color:#CC66CC}

.item a:active {color:#CCCCCC}

 

If you leave out the visited, or put them in the wrong order ... you will pull your hair out debugging because it will default to the initial TAG designation.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.