"Button Slide text search"
Bootstrap 3.0.0 Snippet by bnk2972

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-md-4"> <div class="box-search"> <input type="text" id="search" class="form-control"> <div class="tab-search"> <label for="search"> <span class="glyphicon glyphicon-search"></span> </label> </div> </div> <div class="box-search m-t-20"> <input type="text" placeholder="Search" id="search-2" class="form-control"> <button type="submit" class="btn btn-default">Submit</button> <div class="tab-search-2"> <label for="search-2"> <span class="glyphicon glyphicon-search"></span> </label> </div> </div> </div> </div> </div>
body { padding: 100px; } .box-search { position: relative; overflow: hidden; width: 300px; height: 35px; } .tab-search { margin-left: 36px; width: 100%; position: absolute; top: 0; left: -36px; height: 35px; background: #fff; transition: left .5s; -webkit-transition: left .5s; -o-transition: left .5s; -moz-transition: left .5s; } .tab-search-2 { margin-left: 36px; width: 100%; position: absolute; top: 0; left: -36px; height: 35px; background: #fff; transition: left .5s; -webkit-transition: left .5s; -o-transition: left .5s; -moz-transition: left .5s; } .tab-search-2 > label { border-radius: 50%; border: 1px solid #ddd; width: 35px; background: #ddd; text-align: center; line-height: 36px; float: right; margin: 0; height: 35px; font-size: 16px; cursor: pointer; } .tab-search-2 > label:hover { opacity: .7; } .tab-search-2.open { left: -100%; border-radius: 60px; } .tab-search.open { left: -100%; border-radius: 60px; } .box-search > input[type="text"]:focus { border: 1px solid #ddd; box-shadow: none; } .box-search > input[type="text"] { width: 100%; border-radius: 60px; height: 100%; padding-left: 40px; } .m-t-20 { margin-top: 20px; } .box-search > .tab-search > label:hover { opacity: .7; } .box-search > .tab-search > label { border-radius: 50%; border: 1px solid #ddd; width: 35px; background: #ddd; text-align: center; line-height: 34px; float: right; margin: 0; height: 35px; font-size: 16px; cursor: pointer; } .box-search > button { position: absolute; top: 0; right: 0; height: 100%; border-top-right-radius: 60px; border-bottom-right-radius: 60px; } .box-search > button:focus { outline: none; }
$(document).ready(function() { $(".tab-search > label").click(function() { if ($(".tab-search").hasClass("open")) { $(".tab-search").removeClass("open"); } else { $(".tab-search").addClass("open"); } }); $(".tab-search-2 > label").click(function() { if ($(".tab-search-2").hasClass("open")) { $(".tab-search-2").removeClass("open"); } else { $(".tab-search-2").addClass("open"); } }); $(".main-button").click(function() { if ($(".sub-button-list").hasClass("open")){ $(".sub-button-list").removeClass("open"); } else { $(".sub-button-list").addClass("open"); } }); });

Related: See More


Questions / Comments: