简体   繁体   中英

Bootstrap 4 Font-awesome input icons

I'm trying to figure out how to add font-awesome icons to my input fields. I found a design that I really like and I need to fit icons in the input field. This is what it looks like: 在此处输入图片说明

But my form looks like this, And I can't really figure out how to add them in. I looked for numerous answers but none of them worked out for me as always I hope I can find the answer here. 在此处输入图片说明

Anyhow, This is the code for the form.

 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous"> <script src="https://use.fontawesome.com/f4737361cc.js"></script> <form class="" method="POST" action=""> <div class="row"> <div class="col-md-12"> <div class="form-group"> <i class="fa fa-user-o"></i> <input id="email" type="email" class="form-control custom-input" name="email" value="" placeholder="Email adress" required autofocus style="border-radius: 30px;"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> <i class="fa fa-lock"></i> <input id="password" type="password" class="form-control custom-input" name="password" placeholder="Wachtwoord" required style="border-radius: 30px;"> </div> </div> </div> </form>

Thanks in advance

you can set the position:absulote to .fa then add position:relative to .form-control

 form i.fa { position: absolute; top: 6px; left: 20px; color: blue; font-size: 22px; z-index: 9999; } .form-control { position: relative; padding-left: 45px !important; }
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous"> <script src="https://use.fontawesome.com/f4737361cc.js"></script> <form class="" method="POST" action=""> <div class="row"> <div class="col-md-12"> <div class="form-group"> <i class="fa fa-user-o"></i> <input id="email" type="email" class="form-control custom-input" name="email" value="" placeholder="Email adress" required autofocus style="border-radius: 30px;"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}"> <i class="fa fa-lock"></i> <input id="password" type="password" class="form-control custom-input" name="password" placeholder="Wachtwoord" required style="border-radius: 30px;"> </div> </div> </div> </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM