Bootstrap 3.2.0 Glyphicons not working

三世轮回 提交于 2019-12-10 22:05:38

问题


I'm new to bootstrap & its glyphicons are not working for me. After I've inspect the code, font-family of glyphicon-user was "Helvetica Neue",​Helvetica,​Arial,​sans-serif & not Glyphicons Halflings. Am I missing something or do i need to change the css file.

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
<form>
    <div class="row">
        <div class="col-xs-4">
            <div class="input-group">
                <span class="input-group-addon">
                    <span class="glyphicon-user"></span>
                </span>
                <input type="text" class="form-control" placeholder="Username"/>
            </div>
        </div>
        <div class="col-xs-4">
            <div class="input-group">
                <input type="text" class="form-control" placeholder="Amount">
                <span class="input-group-addon">.00</span>
            </div>
        </div>
        <div class="col-xs-4">
            <div class="input-group">
                <span class="input-group-addon">$</span>
                <input type="text" class="form-control" placeholder="US Dollar">
                <span class="input-group-addon">.00</span>
            </div>
        </div>
    </div>
</form>
</body>
</html>

回答1:


You need to add the class glyphicon.

So your span should actually be:

<span class="glyphicon glyphicon-user"></span>

As shown in the documentation: http://getbootstrap.com/components/#glyphicons-how-to-use




回答2:


It's not enough to name the glyph, you have to use the class glyphicon too.

<span class="glyphicon glyphicon-user"></span>

Also, beware if you are using this in Opera mobile emulator. It doesn't support these fonts properly so you'll get a blank square.




回答3:


Follow the steps to work Glyphicons icons in your boostrap project:

  1. add fonts folder to your project from recently downloaded from http://getbootstrap.com and below code for sample

<span class="glyphicon glyphicon-user"></span>

Thanks!



来源:https://stackoverflow.com/questions/25466519/bootstrap-3-2-0-glyphicons-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!