Zoltan Zoltan - 3 months ago 6x
HTML Question

Shrink input field in certain screen sizes with bootstrap

I am new to bootstrap.

I try to make a navbar that contains a form and navigation.
I would like to shrink the input field in certain screen sizes.

Right now it looks like this.

This is OK:

enter image description here

In these cases I want to shrink the input field:

enter image description here
enter image description here

Relevant HTML code:

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<a class="navbar-brand" href="#">Site Name</a>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control">
<button type="submit" class="btn btn-success">Subscribe</button>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown Menu <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">First Menu Item</a></li>

How can I achieve this?

Thank you.


You can use this CSS:

.navbar-form .form-control {
  width: 100px; // your width
@media (min-width: 768px) {
  .navbar-form .form-control {
    width: 150px; // your width