twitter-bootstrap Glyphicon 在引导程序 4.1 及更高版本中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49905458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 01:20:40  来源:igfitidea点击:

Glyphicon not working in bootstrap version 4.1 and later

twitter-bootstrapbootstrap-4glyphicons

提问by alhelal

I tried to show a search iconin form but the only button is shown without the glyphs.

我试图在表单中显示一个搜索图标,但显示的唯一按钮没有字形。

<form class="form-inline my-2 my-lg-0">
    <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
    <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</form>  

RESULTenter image description here

结果在此处输入图片说明

I use bootstrap version 4.1. I got the glyphicon code getbootstrap.comand form getbootstrap.com

我使用引导程序版本 4.1。我得到了 glyphicon 代码getbootstrap.com并形成了getbootstrap.com

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />

<form class="form-inline my-2 my-lg-0">
  <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
  <button class="btn btn-outline-success my-2 my-sm-0" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</form>

回答by alhelal

Glyphicons are dropped from Bootstrap V4 and later.

Glyphicons 从 Bootstrap V4 及更高版本中删除。

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<form class="form-inline my-2 my-lg-0">
  <div class="input-group">
    <input class="form-control" type="search" placeholder="Search">
    <div class="input-group-append">
      <div class="input-group-text"><i class="fa fa-search"></i></div>
    </div>
  </div>
</form>

Here, Font Awesomeis used. Refer this answerfor more alternatives to Glyphicons and Font Awesome

这里使用了Font Awesome。有关 Glyphicons 和 Font Awesome 的更多替代方案,请参阅此答案

回答by mlegg

Bootstrap 4 dropped the Glyphicons icon font.

Bootstrap 4 删除了 Glyphicons 图标字体。

https://getbootstrap.com/docs/4.0/migration/#components

https://getbootstrap.com/docs/4.0/migration/#components