When we are making web pages, we often need to add small icons to the input, so here are two more common methods.
Method 1
Use the small icon as the background of the input to insert it, and directly enter the code:
<style type="text/css"> *{ margin: 0; padding: 0; } input{ border: none; } .box{ height: 50px; background: yellow; } .box input{ width: 200px; height: 30px; border-radius: 15px; margin: 10px 0; background: url(image/) no-repeat; background-color: white; background-position: 3px; padding-left: 30px; border: 1px solid black; outline: none; } </style> </head> <body> <div class="box"> <input type="text" class="username" value="search"/> </div> </body>
Method 2
Insert using the i tag
<style type="text/css"> *{ margin: 0; padding: 0; } .box{ width: 200px; position: relative; } .box .icon-search{ background: url(image/) no-repeat; width: 20px; height: 20px; position: absolute; top: 6px; left: 0; } .box .username{ padding-left: 30px; height: 25px; } </style> </head> <body> <div class="box"> <i class="icon-search"></i> <input type="text" class="username" value="search"/> </div> </body>
Summarize
The above are two ways to add small icons in JS Input introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!