Last active
August 29, 2015 14:07
-
-
Save KANekT/1a4cec0a2e2b3e3e608b to your computer and use it in GitHub Desktop.
BootStrap Spinner
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
<div class="input-group spinner"> | |
<input type="text" class="form-control" value="@Model"> | |
<div class="input-group-btn-vertical"> | |
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-up"></i></span> | |
<span class="btn btn-default"><i class="glyphicon glyphicon-chevron-down"></i></span> | |
</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
(function($) { | |
$('.spinner .btn:first-of-type').on('click', function() { | |
$('.spinner input').val(parseInt($('.spinner input').val(), 10) + 1); | |
}); | |
$('.spinner .btn:last-of-type').on('click', function() { | |
$('.spinner input').val(parseInt($('.spinner input').val(), 10) - 1); | |
}); | |
})(jQuery); |
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
.spinner { | |
width: 100px; | |
} | |
.spinner input { | |
text-align: right; | |
} | |
.input-group-btn-vertical { | |
position: relative; | |
white-space: nowrap; | |
width: 18px; | |
vertical-align: middle; | |
display: table-cell; | |
} | |
.input-group-btn-vertical > .btn { | |
display: block; | |
float: none; | |
width: 100%; | |
max-width: 100%; | |
padding: 8px; | |
margin-left: -1px; | |
position: relative; | |
border-radius: 0; | |
-webkit-box-shadow: none; | |
box-shadow: none; | |
} | |
.input-group-btn-vertical > .btn:first-child { | |
border-top-right-radius: 4px; | |
} | |
.input-group-btn-vertical > .btn:last-child { | |
margin-top: -2px; | |
border-bottom-right-radius: 4px; | |
} | |
.input-group-btn-vertical i{ | |
font-size: 10px; | |
left: 3px; | |
position: absolute; | |
top: 2px; | |
} | |
.input-group-btn-vertical > .btn:last-child i{ | |
left: 2px; | |
top: 3px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment