我正在试图弄清楚如何在输入字段中添加字体真棒图标。我发现了一个我非常喜欢的设计,我需要在输入字段中放置图标。这就是它的样子:
但是我的表格看起来像这样,而且我无法弄清楚如何添加它们。我寻找了很多答案,但没有一个对我来说一如既往,我希望我能在这里找到答案。
无论如何,这是表格的代码。
<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>
提前致谢
答案 0 :(得分:1)
您可以将position:absulote
设置为.fa,然后将position:relative
添加到.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;
}
&#13;
<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>
&#13;