【问题标题】:Icon not showing in the input group输入组中未显示图标
【发布时间】:2021-11-09 22:04:06
【问题描述】:

我想创建一个输入组,其中包含文本字段和文本字段开头的图标。我有以下代码,它只显示文本字段,我无法找出图标没有出现的原因。

<div class="input-group">
  <div class="input-group-text">
      <i class="fas fa-th-list"></i>
  </div>
  <input type="text" class="form-control" id="location" placeholder="Location">
</div>

如何在占位符之前创建带有图标的输入组或带有图标的输入?上面的代码有什么问题?

【问题讨论】:

    标签: html css input icons bootstrap-5


    【解决方案1】:

    你可以使用form-group row

    <div class="form-group row">
       <label for="staticEmail" class="col-lg-1 col-form-label"><i class="fas fa-th-list"></i></label>
        <div class="col-lg-5">
          <input type="text" readonly class="form-control-plaintext" id="staticEmail" value="email@example.com">
        </div>
      </div>
    </div>
    

    【讨论】:

    • 我试过了,图标还是不可用。
    • 请确保您正确导入 fontawesome 图标
    • 谢谢。我发现我没有导入 fontawesome 图标。我从cdnjs.com/libraries/font-awesome 添加了cdn,它起作用了。
    猜你喜欢
    • 2013-08-20
    • 1970-01-01
    • 2020-09-12
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2020-09-19
    • 1970-01-01
    相关资源
    最近更新 更多