Ricardo
Ricardo

Reputation: 699

Bootstrap Glyphicons not showing

I´m using bootstrap 3 and I put one Glyphicons side by side with a input text and Glyphicons not showing (but the btn-info show) I'm using: class="input-group" to envolve the glyphicon, input text and submit button.

here is the code:

<body>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
                    <span class="sr-only">Toggle navigation</span> 
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button> 
                <a class="navbar-brand" href="#">Meu Site</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">News</a></li>
                    <li><a href="#">Login</a></li>
                    <li><a href="#">Create Account</a></li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container -->
    </nav>

    <div class="container">
        <div class="row">
            <div class="span7 text-center col-md-4 col-md-offset-3" style="float: none; margin-left: auto;margin-right: auto;">
                <img src="../../app.images/logo.jpg" />
            </div>
            <form class="span7 text-center col-md-4 col-md-offset-3" style="float: none; margin-left: auto;margin-right: auto;" role="search">
                <div class="form-group">
                    <label class="radio-inline"><input type="radio" name="optradio">Opt1</label>
                    <label class="radio-inline"><input type="radio" name="optradio" checked="">Opt2</label>
                    <label class="radio-inline"><input type="radio" name="optradio">Opt3</label>
                </div>

                <div class="input-group">
                    <a href="#" class="btn btn-info input-group-btn">
                      <span class="glyphicon glyphicon-th"></span>
                    </a>
                    <input class="form-control " type="text" placeholder="Search" />
                    <div class="input-group-btn">
                        <button class="btn btn-default" type="submit">Search</button>
                    </div>
                </div>
            </form>
            <div class="span7 text-center col-md-4 col-md-offset-3" style="float: none; margin-left: auto;margin-right: auto;">
                Slogan
            </div>
            <div class="span7 text-center col-md-4 col-md-offset-3" style="float: none; margin-left: auto;margin-right: auto;">
                <a href="#">Mobile</a>
                <a href="#">Addons</a>
                <a href="#">Contact</a>
            </div>
        </div>
    </div>
</body>

Upvotes: 6

Views: 13708

Answers (3)

Jonca33
Jonca33

Reputation: 3493

After reading many threads on this topic, here's the solution I came up that finally fixed my Glyphicon bug:

Find directory fonts

directory path: node_modules/bootstrap/fonts

Copy & paste fonts directory into your sourced bootstrap directory from which you've been developing already.

I'm using Grunt as my task manager, therefore in my Gruntfile.js I made sure to grunt the following:

copy: {
        main: {
            expand: true,
            cwd: "node_modules/",
            src: [

                "bootstrap/dist/css/bootstrap.min.css",
                "bootstrap/dist/css/bootstrap.min.css.map",
                "bootstrap/*.*",
                "bootstrap/**/*.*"
            ],

            "dest": "server/public/vendor/"
        }
    },

My tears finally went away afterwards :)

Upvotes: 1

David Moreno Garc&#237;a
David Moreno Garc&#237;a

Reputation: 4523

Seems to be caused by .input-group-btn. There is a rule to set font-size of this element to 0. Add an style rule with this:

div.container a.input-group-btn {
    font-size: 14px;
}

Working sample

Upvotes: 8

Tim Lewis
Tim Lewis

Reputation: 29258

Bootply Example

I'll post this as an alternative to your search bar:

<div class="input-group">
  <span class="input-group-btn">
    <button class="btn btn-info" type="button"><span class="glyphicon glyphicon-th"></span></button>
  </span>
  <input type="text" class="form-control" placeholder="Search for...">
  <div class="input-group-btn">
    <button class="btn btn-default" type="submit">Search</button>
  </div>
</div><!-- /input-group -->

Basically, replace this code:

<div class="input-group">
  <a href="#" class="btn btn-info input-group-btn">
    <span class="glyphicon glyphicon-th"></span>
  </a>
  <input class="form-control " type="text" placeholder="Search" />
  <div class="input-group-btn">
    <button class="btn btn-default" type="submit">Search</button>
  </div>
</div>

With the one above, and add a Javascript handler to the button if you want to navigate somewhere (notice it's not an <a> tag anymore).

Hope this helps!

Note

The issue (I think) arises from using input-group-btn on an <a> tag that's styled as a button. In the Bootstrap examples, the input-group-btn is a span with a <button> tag inside it. You could also try putting the <span class="input-group-btn"> around your <a> tag and seeing if that makes a difference.

Upvotes: 0

Related Questions