Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
How to make dynamic roll over effect images with html?

 
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum
Author Message
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: How to make dynamic roll over effect images with html? Reply with quote

What would be the best way to make a dynamic roll over effect in a website? Images or text are better for thr roll over or hover effect? Also someone knows of a good free script for a beautiful image roll over effect?

Thank you.

Last edited by dude on Tue Aug 24, 04 3:25 pm; edited 1 time in total
Fri Aug 06, 04 6:08 am
Back to top
dude View user's profile Send private message Visit poster's website
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Easy image or text rollover with javascript or css Reply with quote

There are literally thousand ways to do image rollovers with CSS and javascript for your web page. Personally I do not like image roll overs for links and navigations. They offer little to the functionality or look of the page. Instead use CSS to get a hover effect. But anyway, let me show you a very easy way to do image rollovers with javascript first.

The HTML for any image on your web page is like below as we all know:
<img src="image.jpg" name="idname" border=0>

In the above the tag is little different from usual though. Here we have a name associated with the image that is really usefull for our purpose, with the name we are declaring the IMG tag as an object and any browser can find it easy.

Then you have to change that image in a link with a OnMouseOver and OnMouseOut.
Normally links are declared like this:

<a href="#"> anchor text<a/>
Let us make it roll now. Make an image as a link, and in the link put this code.

<a haref="# OnMouseOver="idname.src='image1.jpg'" OnMouseOut="idname.src='image2.jpg'"><img src="image.jpg" name="thumb" border=0></a>

And you are done.

This is the explanation of this little code.

href="#" means that your link is a blank link but you can write any link you need.
OnMouseOver this is a behavior of your link, when you pass your mouse over the link it's going to change the scr of mytext object image with thumbnail_text_over.jpg.
OnMouseOut this restore your image before you roll over your mouse.

With CSS you can achieve the same image rollover effect like this:

Code:
#menu a {
   ...
   background: url("button.gif") top left no-repeat;
   }
#menu a:hover {
   ...
   background-image: url("button-over.gif");
   }
#menu a:active {
   ...
   background-image: url("button-active.gif");
   }


But as I said, I do not like image roll over effects for web site. Instead look at how we used a roll over hover effect on quantumcloud site. The CSS code for achieving such effects are posted below. This does not increase the page size and goes smoothly.

Code:
a:link{ color: #cc6600;   
   border-width: 1px;
    border-top: 0px;
    border-left: 0px;
    border-right: 0px;
    border-bottom: 1px;
    border-color: #cccccc;
    border-style: solid;
   margin-left: 5px;
   margin-right: 5px;
   margin-top: 1px;
   margin-bottom: 1px;
    FONT-SIZE: 10pt;
   FONT-FAMILY: times new roman;
   letter-spacing: 0.00em;
    font-weight: normal;
    font-style: normal;
    text-decoration: none}

a:visited{color: #cc6600;
    FONT-SIZE: 10pt;
   FONT-FAMILY: times new roman;
   letter-spacing: 0.00em;
   margin-left: 5px;
   margin-right: 5px;
   margin-top: 1px;
   margin-bottom: 1px;
   border-width: 1px;
    border-top: 0px;
    border-left: 0px;
    border-right: 0px;
    border-bottom: 1px;
   border-color: #cccccc;
    border-style: solid;
    font-weight: normal;
    font-style: normal;
    text-decoration: none}

a:hover{color: #000000;    
   border-width: 1px;
    border-top: 0px;
    border-left: 0px;
    border-right: 0px;
    border-bottom: 1px;
    border-color: #cc6600;
    border-style: solid;
     margin-left: 5px;
     margin-right: 5px;
     margin-top: 1px;
     margin-bottom: 1px;
    FONT-SIZE: 10pt;
   FONT-FAMILY: times new roman;
   letter-spacing: 0.00em;
    font-weight: normal;
    font-style: normal;
    text-decoration: none}


The above looks very much like an image rollover, yet it's only text, and thus, loads very quickly!
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.


Last edited by quantum on Mon Oct 18, 04 9:24 pm; edited 2 times in total
Sun Aug 08, 04 6:22 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: CSS image roll over effect Reply with quote

Too many options. Choices choices choices. I think, I will take the CSS image rollover technique. It will work from the style sheet right? Nevermind, I shall be able to figure that part out myself. Thank you.
Sun Aug 08, 04 7:34 am
Back to top
dude View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group