Link inside of input tag

后端 未结 3 954
后悔当初
后悔当初 2020-12-19 03:56

How to display a a href and a img src inside a input box (text box). ex: i want to display this inside a text box (

3条回答
  •  感情败类
    2020-12-19 04:09

    You have two options.

    1. Place the image as a background of the input, but this won't be clickable.
    2. Absolutely position the element over an input.

    1:

    .myInput { background:url(path/to/img.jpg) 5px 5px no-repeat; }
    

    2:

    HTML

    CSS

    .inputContainer { position:relative; }
    .myInput { padding-left:25px; /* This will move the text from under the image */ } 
    .inputImg { left:5px; position:absolute; top:5px; z-index:5; }
    

    You'll need to play with the position and values depending on your input size, image size and general placement, but that should do what you want.

提交回复
热议问题