Reputation: 119
I want to make an image button with HTML and CSS. So I tried background:url()
but it's not working. I also tried these:
background: url(res/play.png)
background: url("res/play.png")
background: url("/res/play.png")
background: url(/res/play.png)
background-image: url(res/play.png)
They all not working. This is my directory structure.
MyProgram
└ res directory
└ style.css
└ index.html
This is my code. The image is in res
directory.
<table>
<tr>
<td>
<button id="previousButton"></button>
<button id="playButton"></button>
<button id="nextButton"></button>
</td>
<td>
<input type="range" id="volumeSlider" min="0" max="100" value="50" step="1">
<button id="muteButton"></button>
</td>
</tr>
</table>
button#playButton {
background: url(res/play.png);
}
Upvotes: 0
Views: 445
Reputation: 1271
you can try adding width and height. The background itself is not content, therefore nothing will be shown in your case.
button#playButton {
background: url('res/play.png');
height: 100px;
width: 150px;
}
Upvotes: 1