i've been trying to change the background image of the input button through css, but it doesn't work.
search.html:
<body>
<form name="myform" class="wrapper">
<input type="text" name="q" onkeyup="showUser()" />
<input type="button" name="button" value="Search" onclick="showUser()" class="button"/>
<p>
<div id="txtHint"></div>
</p>
</form>
</body>
search.css:
.button {
background-image: url ('/image/btn.png') no-repeat;
cursor:pointer;
}
what could be wrong?
even inline-ing the css didn't seem to work.
You need to type it without the word
image
.background: url('/image/btn.png') no-repeat;
Tested both ways and this one works.
Example:
If this is a submit button, use
<input type="image" src="..." ... />
.http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_IMAGE.html
If you want to specify the image with CSS, you'll have to use
type="submit"
.background-image
takes an url as a value. Use eitheror
which is a shorthand for
Also, you might want to look at the
button
HTML element for fancy submit buttons.Just to add to the answers, I think the specific reason in this case, in addition to the misplaced
no-repeat
, is the space betweenurl
and(
: