LeeBrooks3
LeeBrooks3

Reputation: 38

How to set a background image to a button via CSS?

I have the following HTML:

<button id='addEVENT' class='normal b-all'></button>

And this CSS:

#addEVENT { 
    width:50px;
    height:25px;
    background:#EEEEEE url('icons/444444/pencil.png') no-repeat fixed center;
}

The 'normal' class adjusts the font style and the 'b-all' adds a border to replace the ugly default ones. The colour shows but not the image, I have tried many variations of CSS but to no avail. Any suggestions?

Upvotes: 0

Views: 3649

Answers (1)

Jon
Jon

Reputation: 437336

The path icons/444444/pencil.png is relative to the location of the CSS file. Assuming that the CSS is inside css/, this would mean that you are pointing to css/icons/444444/pencil.png.

If this is not correct, modify the path accordingly (e.g. ../icons/444444/pencil.png).

Upvotes: 3

Related Questions