<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.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 navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
	
    <div class="collapse navbar-collapse" id="myNavbar">
		<div class="flex">
			<div id="side">
				<ul class="nav navbar-nav navbar-right">
					<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>
			</div>
			<div class="" id="main">
			  <ul class="nav navbar-nav">
				<li class="active"><a href="#">Home</a></li>
				<li class="dropdown">
				  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
				  <ul class="dropdown-menu">
					<li><a href="#">Page 1-1</a></li>
					<li><a href="#">Page 1-2</a></li>
					<li><a href="#">Page 1-3</a></li>
				  </ul>
				</li>
				<li><a href="#">Page 2</a></li>
				<li><a href="#">Page 3</a></li>
			  </ul>
			  
			</div>
		</div>
     </div>
  </div>
</nav>
  
<div class="container">
	<div id="dv1"  style="margin-top:40px;width:60px;height:30p;background-color:gray;">

	</div>
  <h3>Collapsible Navbar</h3>
  <p>In this example, the navigation bar is hidden on small screens and replaced by a button in the top right corner (try to re-size this window).
  <p>Only when the button is clicked, the navigation bar will be displayed.</p>
</div>

</body>
</html>
.flex { display: flex; 
		flex-direction: column;}
	      /* 
	.centermenu{
		justify-content: center;
    		align-items: center;
		text-align:center;
			}*/
	#main { order: 1; }
	#side { order: 2; }
$(document).ready(function(){
	if ( $(window).width() < 768) {
			$("#dv1").css("background-color","pink");
			$("#side").css("order","2");
			$("#main").css("order","1");
			
			//$("#side").css("-webkit-order","2");
			//$("#main").css("-webkit-order","1");
			}
		
		else {
			$("#dv1").css("background-color","lightgreen");
			$("#side").css("order","1");
			$("#main").css("order","2");	
			}
			
    $(window).resize(function(){
	$("#dv1").text($(window).width());
		if ( $(window).width() < 768) {
			$("#dv1").css("background-color","pink");
			$("#side").css("order","2");
			$("#main").css("order","1");
			
			$("#side").css("-webkit-order","2");
			$("#main").css("-webkit-order","1");
			}
		
		else {
			$("#dv1").css("background-color","lightgreen");
			$("#side").css("order","1");
			$("#main").css("order","2");
			$(".flex").css("text-align","center;");	
			}
    })
})
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.