Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- Default bootstrap navbar example -->
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse lateral-left" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<!-- /Default bootstrap navbar example -->

<h1>Lateral opening bootstrap navbar for mobile devices</h1><hr>
<h3>How to implement:</h3>
<h4>HTML-Code</h4>
<ol>
  <li>Include Bootstrap and jQuery</li>
  <li>Add a default <a href="https://getbootstrap.com/components/#navbar" target="_blank">Bootstrap Navbar</a> to your document.</li>
  <li>Add the class <strong>lateral-left</strong> or <strong>lateral-right</strong> to your collapsible navigation element, depending on the opening direction you desire.</li>
</ol>

<h4>CSS-Code</h4>
<ol>
  <li>Insert the CSS code at the bottom of your CSS document.</li>
  <li>Play around with the animation values and adjust your styling until it fits your needs.</li>
  <li>.navbar-collapse has an offset here: <strong>width:calc(100% - 60px);</strong>. You might want to change this, too.</li>
</ol>

<h4>JS-Code</h4>
<ol>
  <li>Insert the JS code at the bottom of your JS document.</li>
</ol>
              
            
!

CSS

              
                @media(max-width:767px){
  .navbar .navbar-collapse.collapsing{ 
    height:auto !important;
  }
  .navbar .lateral-left{
    left:-100%; 
    animation: slide-out-left 200ms forwards;
  }
  .navbar .lateral-left.open{ 
    animation: slide-in-left 200ms forwards;
  }
  .navbar .lateral-right{
    right:-100%;
    animation: slide-out-right 200ms forwards;
  }
  .navbar .lateral-right.open{ 
    animation: slide-in-right 200ms forwards;
  }
  .navbar .navbar-collapse{ 
    top:0px; bottom:0px; 
    position:fixed; 
    width:80%; width:calc(100% - 60px); 
    max-width:320px; 
    height:auto !important;

    /* Optional styling */
    background:#f8f8f8;
    padding:30px;
    top: 52px;
  }
  .navbar .lateral-left.open,
  .navbar .lateral-right.open{
    display:block !important;
    overflow-y:auto;
  }
}

@keyframes slide-in-left{ 
  0%		{ left:-100%; }
  100%	{ left:0px; }
}
@keyframes slide-out-left{
  0%		{ left:0px; }
  100%	{ left:-100%; }
}
@keyframes slide-in-right{ 
  0%		{ right:-100%; }
  100%	{ right:0px; }
}
@keyframes slide-out-right{
  0%		{ right:0px; }
  100%	{ right:-100%; }
}
              
            
!

JS

              
                // Menu side toggle
$('document').ready(function(){
  $('button.navbar-toggle').click(function(){
    var navbar_obj = $($(this).data("target"));
    navbar_obj.toggleClass("open");
  });
});
              
            
!
999px

Console