很难将此图标强制放在输入的右侧而不是下方。已经更改了编号,放入div等。但没有。以下是它现在的样子:
我的代码是(示例未显示结束表单标记):
<form class="pptReg" role="form" name="pptReg" novalidate>
<h1 style="padding-top: 60px; color: #ab2328;">Participant Information</h1>
<div class="form-group col-md-3 naviaInp" style="padding-top: 30px;">
<label for="empCode">Employer Code</label>
<input type="text" name="empCode" class="form-control" id="empCode" data-ng-model="pptregistration.coCode" ng-required="true" maxlength="3" autofocus ng-blur="getEmpIdType(true);">
<a class="questionIcon" href="#"><i class="fa fa-question-circle col-md-2 fa-2x" style="float: right;"></i></a>
<div ng-show="(pptReg.$submitted || pptReg.empCode.$touched) && pptReg.empCode.$error.required">
<p class="claimError"><i class="fa fa-exclamation-circle"></i><span>This is a required field.</span></p>
</div>
<div ng-show="(pptReg.$submitted || pptReg.empCode.$touched) && empIdType == ''">
<p class="claimError"><i class="fa fa-exclamation-circle"></i><span>The Employer Code is invalid.</span></p>
</div>
</div>
它只是一个字体真棒图标我试图添加到输入的右侧。我使用Bootstrap 3进行布局。
想法或建议(我自己经历了许多想法!)?
非常感谢。
答案 0 :(得分:2)
在问号中添加display: inline;
:
<a class="questionIcon" href="#"><i class="fa fa-question-circle col-md-2 fa-2x" style="float: right; display:inline;"></i></a>
答案 1 :(得分:1)
类 .form-control 将empCode输入作为块元素。您需要在输入中添加样式以允许其他元素与其位于同一行(即float:left; display:inline-block;
)。
答案 2 :(得分:1)
首先,您需要限制输入的宽度,以便图标旁边有足够的空间。然后,您还需要将输入和图标设置为display:inline-block;
,从图标中删除col-md-2
类,因为它是不必要的。最后,将vertical-align:middle;
添加到图标,使其与输入垂直对齐。
<强> HTML:强>
<form class="pptReg" role="form" name="pptReg" novalidate="">
<h1 style="padding-top: 60px; color: #ab2328;">Participant Information</h1>
<div class="form-group col-md-3 naviaInp" style="padding-top: 30px;">
<label for="empCode">Employer Code</label>
<input type="text" name="empCode" class="form-control" id="empCode" data-ng-model="pptregistration.coCode" ng-required="true" maxlength="3" autofocus="" ng-blur="getEmpIdType(true);">
<a class="questionIcon" href="#"><i class="fa fa-question-circle col-md-2 fa-2x"></i></a>
<div ng-show="(pptReg.$submitted || pptReg.empCode.$touched) && pptReg.empCode.$error.required">
<p class="claimError"><i class="fa fa-exclamation-circle"></i><span>This is a required field.</span></p>
</div>
<div ng-show="(pptReg.$submitted || pptReg.empCode.$touched) && empIdType == ''">
<p class="claimError"><i class="fa fa-exclamation-circle"></i><span>The Employer Code is invalid.</span></p>
</div>
</div>
</form>
<强> CSS:强>
.form-control {
display:inline-block;
width:90%;
}
a.questionIcon {
display:inline-block;
vertical-align:middle;
}