When i use
background: url("button.png") top/contain no-repeat;
It will fit the image correctly. But when i make the div clickable, it will receive clicks from all over the div and not only the part with the image on it, can it be fixed somehow?
When i use
background: url("button.png") top/contain no-repeat;
It will fit the image correctly. But when i make the div clickable, it will receive clicks from all over the div and not only the part with the image on it, can it be fixed somehow?
Make sure you have set your div
to:
display: inline-block;
Besides from that, you don't want to have a padding in the div
. Instead only set height and width to the exact dimensions for the button. If you want to align the button you can use margin
.
div.myButton {
background: url("button.png") top/contain no-repeat;
display:inline-block;
padding:0px;
height:30px; /* For example 30px */
width:80px; /* By 80px*/
margin: 10px 0px;
}