html - How can I add a font-awesome icon to an input box without bootstrap? -
i want include font-awesome icon form input, running issues finding solution. looking on site gives questions with bootstrap, including 1 without it. tried adapting code this answer alignment off. how can fix this?
.inner-addon { position: relative; } .inner-addon .fa { position: absolute; padding: 10px; pointer-events: none; } .left-addon .fa { left: 0px;} .left-addon input { padding-left: 30px; }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> <div class="inner-addon left-addon"> <i class="fa fa-adn"></i> <input type="text" class="form-control" placeholder="username" /> </div>
depending on size want input be, add additional padding input:
.left-addon input { padding: 8px 5px 8px 30px; }
or reduce padding on font-awesome icon:
.inner-addon .fa { position: absolute; padding: 3px 6px; pointer-events: none; }
.inner-addon { position: relative; } .inner-addon .fa { position: absolute; padding: 3px 6px; pointer-events: none; } .left-addon .fa { left: 0px;} .left-addon input { padding-left: 30px; } .inner-addon-tall input { padding: 8px 5px 8px 30px; } .inner-addon-tall .fa { padding: 10px; }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> <div class="inner-addon left-addon"> <i class="fa fa-adn"></i> <input type="text" class="form-control" placeholder="username" /> </div> <br/><br/> <div class="inner-addon left-addon inner-addon-tall"> <i class="fa fa-adn"></i> <input type="text" class="form-control" placeholder="username" /> </div>
or combination of them both based on height want.
Comments
Post a Comment