css - In Bootstrap3, how to change the order of collapsed elements in navbar? -


i using bootstrap3 <nav>, in sample code team used navbar-toggle collapsed class collapse elements in navbar on small screen.

my question how change order of them when collapsed? made short snippet:

<html> <head>   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">   <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head>  <body>   <nav class="navbar navbar-default">     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".nav" aria-expanded="false">       <span class="sr-only">options</span>       <span class="icon-bar"></span>       <span class="icon-bar"></span>       <span class="icon-bar"></span>     </button>      <ul class="nav navbar-nav collapse navbar-collapse">       <li class="active"><a href="#">home</a></li>       <li><a href="#">page 1</a></li>       <li><a href="#">page 2</a></li>     </ul>      <div class="navbar-header">       <a class="navbar-brand" href="#">       <img alt="brand" src="some/img.png">       </a>     </div>       <ul class="nav navbar-nav navbar-right collapse navbar-collapse">       <li><a href="#"><span class="glyphicon glyphicon-user"></span> sign up</a></li>       <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> login</a></li>     </ul>   </nav> </body> </html> 

to clarify, in <nav>, left right there list, image, list. when collapsed on small screen, order top bottom, list, image , list. how put image @ top when collapsed?

the easiest way create brand html twice, , make 1 visible on xs , other hidden on xs.

you can adding visible-xs , hidden-xs classes containers want either visible or hidden when navbar collapsed.

by doing can display brand image in both places without having add javascript.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous">      <nav class="navbar navbar-default">    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".nav" aria-expanded="false">      <span class="sr-only">options</span>      <span class="icon-bar"></span>      <span class="icon-bar"></span>      <span class="icon-bar"></span>    </button>      <ul class="nav navbar-nav collapse navbar-collapse">      <li class="dropdown">        <div class="navbar-header visible-xs">          <a class="navbar-brand" href="#">            <img alt="brand" src="some/img.png" />          </a>        </div>        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">          <i class="fa fa-bars" aria-hidden="true"></i>          <span class="caret"></span>        </a>        <ul class="dropdown-menu">          <li><a href="#">link1</a></li>          <li><a href="#">link2</a></li>        </ul>      </li>    </ul>      <div class="navbar-header hidden-xs">      <a class="navbar-brand" href="#">        <img alt="brand" src="some/img.png" />      </a>    </div>      <ul class="nav navbar-nav navbar-right collapse navbar-collapse">      <li class="dropdown">        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">hi! user<span class="caret"></span></a>        <ul class="dropdown-menu">          <li><a href="#"> profile</a></li>          <li><a href="#"> feedback</a></li>          <li role="separator" class="divider"></li>          <li><a href="#"> log out</a></li>        </ul>      </li>    </ul>  </nav>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnipg9mgcd8wgnicpd7txa" crossorigin="anonymous"></script>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -