Place an image inside a text field

后端 未结 10 908
夕颜
夕颜 2021-02-04 04:15

I have an HTML input field like this. I would like to place an image inside the textbox on the right side. Can someone help me out with its CSS for that?



        
10条回答
  •  一向
    一向 (楼主)
    2021-02-04 04:23

    HTML

    CSS

    .fake-input { position: relative; width:240px; }
    .fake-input input { border:none; background-color:#fff; display:block; width: 100%; box-sizing: border-box }
    .fake-input img { position: absolute; top: 2px; right: 5px }
    

    Working demo

    http://jsfiddle.net/HnJZa/

提交回复
热议问题