Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap and search input width change on focus

I am using bootstrap 3 to create my nav bar. I also needed to place a search bar on the navbar. So my code looks like this

<div class="navbar navbar-default">     
    <a class="navbar-brand">Logo Image</a>
    <ul class="nav navbar-nav">
    <li class="active"><a href="#">Calendar</a></li>
    <li><a href="#">Customerr</a></li>
    <li><a href="#">Providers</a></li>                  
    </ul>
    <form class="navbar-form navbar-right" action="">
    <div class="form-group">
        <input type="text" class="form-control mac-style" name="Search" id='nav-search' placeholder="Search">
    </div>
    <input type="submit" name="search" value="Search" class="btn btn-default" > 
    </form>
</div>

I want the input box to get bigger when the usere focuses to search but to the left like stack's search bar. I tried the following css at first

.mac-style:focus{
    width: 500px;
}

and the input box grows to the left but the transition is very rough. So i tried to add the transition property(webkit moz o an default) like this

 .mac-style:focus{
    width: 500px;
    -webkit-transition: width 1s ease-in-out;
    -moz-transition:width 1s ease-in-out;
    -o-transition: width 1s ease-in-out;
    transition: width 1s ease-in-out;
}

but the input changes width to the right going behind the search button and off the nav-bar. Ho can i make it act like the css without the transition(grow to the left). The way my nav bar is created, is there a way to make it stop when it reaches the last li so it is more dynamic?

like image 678
Apostolos Avatar asked Nov 07 '13 09:11

Apostolos


People also ask

How do I change the width of a bootstrap form?

For default size . form-control is used, for smaller size we can use . form-control class along with . form-control-sm and for larger size we can use .

How do you change the width of an input-group?

To set the width of the input-group-text , just change the value of the flex of the input-group , for instance, as seen above 30% of the total width.

How do I make the input field smaller in bootstrap?

Use the . input-sm class to set small input field in Bootstrap.

How do I reduce the size of a text box in bootstrap?

We can also adjust the size of input elements in bootstrap by the use of classes like . input-lg and . input-sm for adjusting heights and . col-lg* and .


1 Answers

If i correctly understand you - take a this fiddle . I don't know yours other css styles, but you can a create your fiddle and show it to us.

like image 58
BordiArt Avatar answered Oct 15 '22 12:10

BordiArt