Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting a image inside a input box

Tags:

css

Similar to Put icon inside input element in a form

But how to I get the icon inside and on the right side of the box?

like image 604
Jason94 Avatar asked Aug 15 '11 06:08

Jason94


2 Answers

Try this:

background: url(images/icon.png) no-repeat right center;

The explanation for this CSS is as follows:

background: [url to image] [don't repeat] [horizontal position] [vertical position]

like image 160
Bazzz Avatar answered Sep 22 '22 18:09

Bazzz


As an addition to Bazzz's answer, if you don't want the icon right up against the right border, you can specify padding on the right side.

background: url(images/icon.png) no-repeat right 10px center;

This will put the icon on the right side, but keep it 10 pixels from the very edge. So, the CSS explanation would look like this:

background: [URL to icon] [specify no repeating] [horizontal position] [padding on right side] [vertical position]

like image 29
Chris Avatar answered Sep 22 '22 18:09

Chris