Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set background image in submit button?

Tags:

css

xhtml

how to set background image in submit button?

I have to use a image in place of regular submit button? which way would be best in xhtml/css?

Button should look same in all main browsers including IE6,IE7

like image 295
Jitendra Vyas Avatar asked Mar 15 '10 03:03

Jitendra Vyas


People also ask

How do I put a background image on a button?

The default button in HTML can be changed to an image using CSS. The required button is selected using the respective CSS selector. The background property can then be set to include a background image and change the image type as required. The border of the button can also be removed to show only the image itself.

How do I add a background image in react?

export default App; Output: Method 5: Add background image from src/ folder If the image resides inside the src directory, the user can import it inside the component filer and set it as the background image. In this file, we will import the image and set it as a background image of the div element.


2 Answers

The way I usually do it, is with the following css:

div#submitForm input {   background: url("../images/buttonbg.png") no-repeat scroll 0 0 transparent;   color: #000000;   cursor: pointer;   font-weight: bold;   height: 20px;   padding-bottom: 2px;   width: 75px; } 

and the markup:

<div id="submitForm">     <input type="submit" value="Submit" name="submit"> </div> 

If things look different in the various browsers I implore you to use a reset style sheet which sets all margins, padding and maybe even borders to zero.

like image 144
Phaze Phusion Avatar answered Sep 21 '22 06:09

Phaze Phusion


.button {     border: none;     background: url('/forms/up.png') no-repeat top left;     padding: 2px 8px; } 
like image 45
muruga Avatar answered Sep 24 '22 06:09

muruga