How to add background image for input type="button"?
You need to type it without the word image
.
background: url('/image/btn.png') no-repeat;
Tested both ways and this one works.
Example:
<html>
<head>
<style type="text/css">
.button{
background: url(/image/btn.png) no-repeat;
cursor:pointer;
border: none;
}
</style>
</head>
<body>
<input type="button" name="button" value="Search" onclick="showUser()" class="button"/>
<input type="image" name="button" value="Search" onclick="showUser()" class="button"/>
<input type="submit" name="button" value="Search" onclick="showUser()" class="button"/>
</body>
</html>
Just to add to the answers, I think the specific reason in this case, in addition to the misplaced no-repeat
, is the space between url
and (
:
background-image: url ('/image/btn.png') no-repeat; /* Won't work */
background-image: url('/image/btn.png'); /* Should work */