How to create a "send button" button?

I am creating an HTML contact form that uses a standard image for a submit button.

Here is the html:

<form action="#">
    <fieldset>
        <input type="text" name="name" value="FULL NAME" onfocus="if (this.value=='FULL NAME') this.value='';"/>
        <input type="text" name="" value="PHONE NUMBER" onfocus="if (this.value=='PHONE NUMBER') this.value='';"/>
        <input type="text" name="" value="EMAIL" onfocus="if (this.value=='EMAIL') this.value='';"/>
        <input type="text" name="" value="MOVE DATE" onfocus="if (this.value=='MOVE DATE') this.value='';"/>
        <input type="text" name="" value="ORIGINATING ADDRESS" onfocus="if (this.value=='ORIGINATING ADDRESS') this.value='';"/>
        <input type="text" name="" value="DESTINATION ADDRESS" onfocus="if (this.value=='DESTINATION ADDRESS') this.value='';"/>
        <select name="type">
            <option value="Private">Private</option>
            <option value="Commercial">Commercial</option>
        </select>
        <input id="quoteSubmit" type="image" src="_images/btn_submit.png" alt="" />
    </fieldset>
</form>

The static image of the submit button is fine, but I would like to change it from mouseover to btn_submit-over.png.

I am familiar with the mouse using css sprites, but they do not work for submit buttons. I would appreciate help.

Thank!

+3
source share
6 answers

With pure CSS,

<input type="submit" value="::Submit Query::" id="foo" />

...

  #foo {
    background-image: url('_images/btn_submit.png');
    width: <width here>;
    height: <height here>;
    border-style: none;
    background-color: transparent;
    text-indent: 480px;    /* hack to hide the text */
  }

  #foo:hover {
    background-image: url('_images/btn_submit-over.png')
  }

If CSS is disabled, it will revert to a simple submit button.

Demo: http://jsbin.com/aboxu3/2

Then you can apply CSS sprite methods.

+6
source

... jquery , .


<input id="quoteSubmit" type="image" src="_images/btn_submit.png" alt="" />

to
<input id="quoteSubmit" type="image" src="_images/btn_submit.png" alt="" onmouseover="javascript:this.src='_images/btn_submit-over.png'" onmouseout="javascript:this.src='_images/btn_submit.png'"/>

, , .

Br,

+3

( Mitch ):

HTML FORM 'class':

<INPUT NAME="submit" class="submit" TYPE="submit" VALUE="Submit">   

CSS ( 'width:' 'height:', )

.submit {
text-decoration: none;
text-align: center;
border: 1px solid black;
background-color: #cccccc;
-moz-border-radius: 5px; /* I hate square buttons for mozilla*/
border-radius: 5px; /* I hate square buttons for everybody else*/
font-family: Arial,Helvetic1,Geneva,Swiss,SunSans-Regular;
font-size: 18px;
color: #0000aa; /* font is blue */
}

.submit:hover {
color: #ff0000; /* font changes to RED on hover) */
}
+3

OldSchool:

        <a href="#" onclick="document.forms[0].submit(); return false"
onmouseover="document.subBut.src=document.subBut.src.replace('.png','over.png')"
onmouseout="document.subBut.src=document.subBut.src.replace('over.png','.png')"><img 
name="subBut" src="_images/btn_submit.png" alt="" border="0" /></a>
+1

?

<input type="submit" class="submit" .../>

CSS:
input.submit:hover{
   color: Green;
} 

JavaScript submit() (javascript: document.theform.submit())

+1

, :

HTML:

<input type="submit" name="Submit" id="submit" value="&nbsp;" />

. CSS. "" &nbsp; ( html ), .

CSS:

#submit {
width: 220px; 
height: 50px;
border: none;
background: url("images/submit.jpg") no-repeat; 
}
        #submit:focus {
        background: url("images/submit_over.jpg") no-repeat;    
        }

Notes. Width and height should be the width and height of your image. Then add border: none; to remove the default border.

Hope this helps! Much simpler than any of the above answers.

+1
source

Source: https://habr.com/ru/post/1753167/


All Articles