CSS To Put Icon Inside An Input Element In A Form - Tutorialspoint
Có thể bạn quan tâm
To show how to put an icon inside an input element in a form using CSS, use the Font Awesome. For adding the font awesome icons on a web page, include the CDN −
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">Place Icons Inside an Input Element
We have used the Font Awesome icons here for Username, Email and password −
<i class="fa fa-user icon"> </i> <input class="Field" type="text" placeholder="Username" /> <div class="inputContainer"> <i class="fa fa-envelope icon"> </i> <input class="Field" type="text" placeholder="Email" /> </div> <div class="inputContainer"> <i class="fa fa-key icon"> </i> <input class="Field" type="password" placeholder="Password" /> </div>Icon for the Username
For the Username, the following icon is included −
<i class="fa fa-user icon"> </i>Icon for the Email-id
For the Email-id, the following icon is included −
<i class="fa fa-envelope icon"> </i>Icon for the Password
For the Password, the following icon is included −
<i class="fa fa-key icon"> </i>Example
Let us see the example to put icon inside an input element −
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } form { max-width: 450px; margin: auto; } .inputContainer i { position: absolute; } .inputContainer { width: 100%; margin-bottom: 10px; } .icon { padding: 15px; color: rgb(49, 0, 128); width: 70px; text-align: left; } .Field { width: 100%; padding: 10px; text-align: center; font-size: 20px; font-weight: 500; } </style> </head> <body> <h1 style="text-align: center;">Icons inside input element example</h1> <form> <div class="inputContainer"> <i class="fa fa-user icon"> </i> <input class="Field" type="text" placeholder="Username" /> </div> <div class="inputContainer"> <i class="fa fa-envelope icon"> </i> <input class="Field" type="text" placeholder="Email" /> </div> <div class="inputContainer"> <i class="fa fa-key icon"> </i> <input class="Field" type="password" placeholder="Password" /> </div> </form> </body> </html>Từ khóa » Html Field Icons
-
How To Create A Form With Icons - W3Schools
-
Put Icon Inside Input Element In A Form - Html - Stack Overflow
-
CSS To Put Icon Inside An Input Element In A Form - GeeksforGeeks
-
How To Add Icons Inside Input Elements In HTML
-
Formatting Icons For The HTML Field Editors
-
Try It Live - Adding Icons Inside And Outside Of Input Text In Forms
-
Form Field Elements Having Icon Inside It - FormGet
-
Input With Icon - OutSystems 11 Documentation
-
How To Add Icons To The Right Inside Html Input Fields Code Example
-
How To Add Font Awesome Icons To Your Input Fields - Solodev
-
How To Use ICONS In Form Fields Properly - YouTube
-
How To Add Icons Inside HTML Input Fields - YouTube
-
Text Fields - Material Design
-
Create A Search Icon Inside Input Box With HTML And CSS