html - Search bar below search button - on click -


i developing webpages angular 4 application using bootstrap 3.

trying add search button (top right/top left) expand in next row on click. refer top right corner search button here.

<div class="row">  <div class="col-xs-3">   <form id="demo-2" style="margin-left: 10px">     <input type="search" placeholder="search..">   </form>  </div> </div> 

css

input {   outline: none; } input[type=search] {   -webkit-appearance: textfield;   -webkit-box-sizing: content-box;   font-family: inherit;   font-size: 100%; } input::-webkit-search-decoration,  input[type=search] {   background: #ededed url(https://static.tumblr.com/ftv85bp/mixmud4tx/search-icon.png) no-repeat 9px center;   border: solid 1px #ccc;   padding: 7px 9px 7px 17px;   width: 55px;    border-radius: 1em;    -webkit-transition: .5s;   -moz-transition: .5s;   transition: .5s; } input[type=search]:focus {   width: 170px;   background-color: #fff;    -webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);   -moz-box-shadow: 0 0 5px rgba(109,207,246,.5);   box-shadow: 0 0 5px rgba(109,207,246,.5); }  #demo-2 input[type=search] {   width: 15px;   padding-left: 10px;   color: transparent;   cursor: pointer; } #demo-2 input[type=search]:hover {   background-color: #fff; } #demo-2 input[type=search]:focus {   width: 200px;   padding-left: 32px;   color: #000;   background-color: #fff;   cursor: auto;   color: black; } #demo-2 input:-moz-placeholder {   color: transparent; } #demo-2 input::-webkit-input-placeholder {   color: transparent; } 

this gives me search bar expand in same row. i've tried examples same. of them talk expanding same row.

note: search bar & search button in same row desktop view. similar this. change responsively mobile view.

thanks in advance. suggestions welcome.

the search button doesn't expanded on next row, toggles new element that's positioned underneath it. check out examples below see mean.

option 1 (with simple jquery code)

$(document).ready(function(){      $(".toggle-search").click(function(){          $(".search-input").toggle();      });  });
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>      <button class="toggle-search"> search </button>  <div class="container">    <form class="row search-input" id="demo-2" style="margin-left: 10px">      <input class="col-lg-12" type="search" placeholder="search..">    </form>  </div>

option 2 (doesn't include additional jquery code still requires jquery library)

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>      <button type="button" class="btn btn-info" data-toggle="collapse" data-target=".search-input"> search </button>  <div class="container collapse search-input">    <form class="row" id="demo-2" style="margin-left: 10px">      <input class="col-lg-12" type="search" placeholder="search..">    </form>  </div>


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -