Reputation: 429
I'm trying put a glyphicon inside input tag html but it's incorrect.
I mean
Code
<input type="text" name="search" id="search_box pull-right" class="form-control search_box" placeholder="Search for..."
<span class="glyphicon glyphicon-search" ></span>
/> <!-- end input -->
Upvotes: 4
Views: 18679
Reputation: 75
Try this:
<head><link rel="stylesheet" type="text/css"
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"></head>
<body>
<div class="topnav">
<form action="">
<input type="text" class="placeicon" placeholder=" Search">
<button class="searchButton" type="submit">Search</button>
</form>
</div>
</body>
And then add external CSS:
.placeicon {
font-family: fontawesome;
}
Upvotes: 1
Reputation: 6652
Just replace this with your markup.
<div class="input-group">
<span class="input-group-addon" id="search-query"><span class="glyphicon glyphicon-search"></span></span>
<input type="text" class="form-control" aria-describedby="search-query">
</div>
It would look like this
and using CSS make the span's background color transparent, like so
#search-icon {
background-color: transparent;
}
#search-icon input {
border-left: 0;
}
Then finally it would look like this(what you want). You could add a placeholder too if you wish.
Upvotes: 2
Reputation: 3489
Try this
<div class="col-sm-6">
<div class="right-inner-addon">
<i class="icon-search"></i>
<input type="search" class="form-control" placeholder="Search" />
</div>
</div>
Upvotes: 3
Reputation: 2735
You can add below this way:
<div class="form-group col-xs-6">
<label class="control-label">
<code>.inner-addon.<i>left</i>-addon</code>
</label>
<div class="inner-addon left-addon">
<i class="glyphicon glyphicon-user"></i>
<input type="text" class="form-control" placeholder="Username" />
</div>
</div>
Upvotes: 0
Reputation: 14199
you are probably looking for input-group-addon
: http://getbootstrap.com/components/#input-groups-basic
Just a note: you can't put tags inside a
input
. Have a look at: https://www.w3.org/TR/html4/index/elements.html
Upvotes: 0