Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Jon's Avatar
    Senior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    1,052
    Downloads
    0
    Uploads
    0

    HTML/CSS Rollover State?

    Hi there

    I'm currently writing my first site using HTML.

    For my main menu I have 4 different images linking to the 4 pages of my site. Is there any way that when you hover over these images they change? I'd like them to go from white text to grey text but I can change that using images.

    I need a code to say if you have image_1.jpg, when the mouse hovers over it it changes to image_2.jpg.

    I'd probably go with CSS as I have a sprite build but will need pretty much step by step instuctions of how to get this working as I'm not too experienced with HTML/CSS. If anyone could supply me a code that would be great.

    I'm not sure if this can be done but if anyone has any alternatives I'd be happy to hear them

    Cheers

  2. #2
    Mel's Avatar
    Senior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    470
    Downloads
    0
    Uploads
    0
    a:link {
    background-image:url('normalState.jpg');
    }

    a:hover {
    background-image:url('hoverState.jpg');
    }

  3. #3
    simbe1's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jun 2011
    Age
    46
    Posts
    116
    Downloads
    0
    Uploads
    0
    you need javascript to do this,here is your code.....
    <!-- place the following code within the <BODY> of your document --> <script language="javascript" type="text/javascript"> normal_image = new Image();
    normal_image.src = "path/img.gif"; mouseover_image = new Image();
    mouseover_image.src = "path/img2.gif"; <!-- repeat the 4 lines above for any subsequent images. --> function swap(){
    if (document.images){
    for (var x=0;
    x<swap.arguments.length;
    x+=2) {
    document[swap.arguments[x]].src = eval(swap.arguments[x+1] + ".src"); }
    }
    }
    </script> <!-- Place this code where you want the rollover buttons to appear.
    Parts to change here: name_of_img (to match <img name="", below),
    Image variable (e.g mouseover_image/normal_image - to match above code),
    href element to your documents url and the img name & src. --> <a href="page.html" onMouseOver="swap('name_of_img','normal_image')"
    onMouseOut="swap('name_of_img','mouseover_image')" >
    <img name="name_of_img" src="path/img.gif" border="0"></a>

 

 

Quick Reply Quick Reply

Click here to log in


What comes after M0nday

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Image Mapping With Rollover Images? (html/css)?
    By Meow Meow in forum Discuss HTML
    Replies: 0
    Last Post: 02-21-2011, 04:10 AM
  2. Image rollover in html? or css?
    By smith smith in forum Discuss HTML
    Replies: 0
    Last Post: 01-12-2011, 04:23 AM
  3. Html and css rollover map code help please?
    By timothy in forum Discuss HTML
    Replies: 0
    Last Post: 01-02-2011, 05:33 AM
  4. Replies: 0
    Last Post: 08-31-2010, 06:56 AM
  5. Rollover text- CSS/HTML?
    By Helga Bon Elmer in forum Discuss HTML
    Replies: 0
    Last Post: 05-11-2009, 10:55 PM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •