Mouse over effect help

Discussion in 'HTML & Website Design' started by bigdogcattle, Nov 4, 2009.

  1. #1
    I have the following code for a sign up form. I want the button to change when the mouse hovers over. Can someone help me? The button that I want it to change to is: sign_up_mouseover.png

    <ul class="site-nav2">
    <p>&nbsp;</p>
    <FORM ACTION="https://app.expressemailmarketing.com/Survey.aspx?SFID=75036" METHOD="POST">
    <div align="center"> <span class="style20"><FONT FACE="arial, helvetica">Sign up for our Mailing List
    </FONT></span>
    <BR>
    <input type="TEXT" name="email" />
    <BR>
    <INPUT TYPE="IMAGE" SRC="images/sign_up.png" ALIGN="ABSMIDDLE" BORDER="0" />
    <INPUT TYPE="HIDDEN" NAME="SkipSurvey" VALUE="FALSE" />
    </div>
    </FORM>
    </ul>




    Thanks
    Jamie
    [​IMG]
     
    bigdogcattle, Nov 4, 2009 IP
  2. tobykw13

    tobykw13 Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This will require a simple javascript function in combination with the onmouseover element within your img tag. Try googling: "Switch image onmouseover"
     
    tobykw13, Nov 4, 2009 IP
  3. Brandon Sheley

    Brandon Sheley Illustrious Member

    Messages:
    9,721
    Likes Received:
    612
    Best Answers:
    2
    Trophy Points:
    420
    #3
    do you have dreamweaver or other web program? it would be real easy if you do
    like the user above said, you're looking for some java script and google is your next best option
     
    Brandon Sheley, Nov 4, 2009 IP
  4. camp185

    camp185 Well-Known Member

    Messages:
    1,653
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Easy....just add the title attribute...see example:

    <INPUT TYPE="IMAGE" SRC="images/sign_up.png" ALIGN="ABSMIDDLE" BORDER="0" title="Hover text" />
     
    camp185, Nov 6, 2009 IP
  5. nehrav

    nehrav Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hmm, for this I will suggest, code for CSS

    and code for input button
    and you can replace background-color to background-image,
    to get the desired effect.
     
    nehrav, Nov 10, 2009 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    If you want to use images like you did, this is pretty simple - AND NO, you do not need javascript for it in any modern browser.

    Though first I'd suggest ditching the HTML 3.2 style markup and attributes you shouldn't even be using anymore.

    The trick is to wrap the button in an anchor.

    <a class="stateButton">
    	<input type="image" src="images/sign_up.png" alt="Sign Up" />
    </a>
    Code (markup):
    This will assume your two button images are 100x32. Combine them to a single 100x64 image one atop the other.
    
    .stateButton {
    	display:block;
    	position:relative;
    	width:100px;
    	height:32px;
    	overflow:hidden;
    }
    
    .stateButton input {
    	position:absolute;
    	display:block; /* IE Fix */
    	top:0;
    	left:0;
    	width:100px;
    	height:64px;
    }
    
    .stateButton:active,
    .stateButton:focus,
    .stateButton:hover {
    	display:inline; /* IE fix */
    	top:-32px;
    }
    
    Code (markup):
    The anchor block container gives us our hover state hook even in IE. By sizing it to the input we'll show it should never fire a click anyways. We make the anchor half the height of our image so it only shows the top half thanks to the overflow state. When we move it up -32px on hover, the lower half is revealed. Oh, IE will sometimes 'stick' in one hover state or the other unless you set each to a unique display state. It's just wierd that way.

    Only 'problem' with this approach is that CSS off the user will see both images... But the advantages of no scripting and using only one image file instead of two far outweighs the negatives in my book.

    Oh, and don't forget your alt text - INPUT is just like IMG in that way. Not everyone has images on.

    The technique of sliding the element inside a overflow:hidden container can also be handy when building a image-replacement sprite menu in that it can mean a LOT less CSS. Slide a background around on a span for the unique button, but slide the span around inside the anchor for the hover states. I just did that with the menu on this rewrite I did for another thread here:

    [url]http://www.cutcodedown.com/for_others/2kungfu4u/template.html[/url]

    Single image file handles the whole menu, while still using a proper list to build it.
    [url]http://www.cutcodedown.com/for_others/2kungfu4u/images/mainMenu.png[/url]

    Slide the background in the span up and down based on the LI's class, slide the span left and right for the hover states. Pretty damned slick.
     
    Last edited: Nov 10, 2009
    deathshadow, Nov 10, 2009 IP