Last active
August 29, 2015 14:05
-
-
Save lightstrike/d3d0a653511638ede586 to your computer and use it in GitHub Desktop.
Embedded Icon in Bootstrap 3 Input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
See http://codepen.io/lightstrike/pen/tswme for demo | |
Example markup and inspiration from http://jsfiddle.net/KyleMit/cyCFS/ | |
--> | |
<p>Full Size:</p> | |
<div class="left-inner-addon "> | |
<i class="glyphicon glyphicon-user"></i> | |
<input type="text" | |
class="form-control" | |
placeholder="Username" /> | |
</div> | |
<div class="right-inner-addon "> | |
<i class="glyphicon glyphicon-search"></i> | |
<input type="search" | |
class="form-control" | |
placeholder="Search" /> | |
</div> | |
<br/> | |
<p>Smaller:</p> | |
<div class="col-xs-6" > | |
<div class="left-inner-addon"> | |
<i class="glyphicon glyphicon-user"></i> | |
<input type="text" | |
class="form-control" | |
placeholder="Username" /> | |
</div> | |
</div> | |
<div class="col-xs-6" > | |
<div class="right-inner-addon"> | |
<i class="glyphicon glyphicon-search"></i> | |
<input type="search" | |
class="form-control" | |
placeholder="Search" /> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Inspiration from http://jsfiddle.net/KyleMit/cyCFS/ */ | |
@mixin inputAddon($position, $padding:9px, $iconAttr:"i", $inputAttr:"input") { | |
position: relative; | |
#{$iconAttr} { | |
position: absolute; | |
#{$position}: 0; | |
padding: $padding; | |
pointer-events: none; | |
} | |
#{$inputAttr} { | |
width: 100%; | |
padding-#{$position}: 30px; | |
} | |
} | |
.left-inner-addon { | |
@include inputAddon("left"); | |
} | |
.right-inner-addon { | |
@include inputAddon("right"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment