Looking for the best way to add an icon to a button on css

Issue

I have a value input. We need to add an icon. What’s the best way to do this?

<input type="button" class="upload" value="Choose File" />`

Now I’m adding positioning absolute:

img {
  position: absolute;
  left: 115px;
  top: 55px;                
}
<img src="/media/colour/group.png" alt="icon" title="arrow icon" />

enter image description here

Solution

You can use it like this:

input[type='button'] {
    background-image: url(/media/colour/group.png);
    background-position: 7px 7px;
    background-repeat: no-repeat;
}

Answered By – Harshit Rastogi

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published