How can you make buttons stretched only when the `navbar` is collapsed (Bootstrap)?


<!doctype html>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" target="_blank" rel="nofollow" href="bower_components/bootstrap/dist/css/bootstrap.css">
  <div class="container-fluid">
    <nav class="navbar navbar-default">
      <div class="navbar-header">
        <a class="navbar-brand" target="_blank" rel="nofollow" href="#">...</a>
        <button aria-expanded="false" class="collapsed navbar-toggle" data-target="#main_menu" data-toggle="collapse" type="button">
          <span class="sr-only">toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
      <div class="collapse navbar-collapse" id="main_menu">
        <form class="navbar-form navbar-right" id="main_menu_form" style="border: none;">
          <input class="form-control" type="text" name="username" placeholder="User name">
          <input class="form-control" type="password" name="password" placeholder="Password">
          <input class="btn btn-success" type="button" value="sign in">
          <input class="btn btn-primary" type="button" value="sign up">
  <script src="bower_components/jquery/dist/jquery.js"></script>
  <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>

I want both Sign In and Sign Up buttons to be stretched equally when the navigation bar is collapsed. I have tried using flex box, it succeed, however it also ruins the layout when the navigation bar is not collapsed. What should I do?

You can use the @media css rule to set values on selectors based on specific properties (like screen with).

@media screen and (max-width: 768px) {
  .navbar-collapse input[type="submit"] {
    width: 49%;

Here is your jsfiddle: