Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <section class="bg-primary">
  <div class="container">

<!--  START NAVBAR   -->
    <nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark navbar-offcanvas">
      <a class="navbar-brand mr-auto" href="#">Offcanvas navbar - toggle always visible</a>
<!--     If you want to show the button online on mobile use this toggle   
      <button class="navbar-toggler p-0 border-0" type="button" data-toggle="offcanvas">
        <span class="navbar-toggler-icon"></span>

<!--      This toggle button is always visible  -->
     <button class="navbar-toggler d-block" type="button" id="navToggle">
      <span class="navbar-toggler-icon"></span>

      <div class="navbar-collapse offcanvas-collapse">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#">Dashboard <span class="sr-only">(current)</span></a>
          <li class="nav-item">
            <a class="nav-link" href="#">Notifications</a>
          <li class="nav-item">
            <a class="nav-link" href="#">Profile</a>
          <li class="nav-item">
            <a class="nav-link" href="#">Switch account</a>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="https://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Settings</a>
            <div class="dropdown-menu" aria-labelledby="dropdown01">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
<!--  END NAVBAR   -->

  <!--/.container    -->


  <div class="container py-3">
    This demo is a remix of the <a href="http://getbootstrap.com/docs/4.1/examples/offcanvas/">off canvas example</a>  on the Bootstrap 4 documentation.

body {
  overflow-x: hidden; /* Prevent scroll on narrow devices */

/* since the navbar is fixed we need to add some space to the body */
body {
  padding-top: 56px;

  .offcanvas-collapse {
    position: fixed;
    top: 56px; /* Height of navbar */
    bottom: 0;
    right: 100%;
    width: 300px;
    padding-right: 1rem;
    padding-left: 1rem;
    overflow-y: auto;
    visibility: hidden;
    background-color: #343a40;
    transition-timing-function: ease-in-out;
    transition-duration: .3s;
    transition-property: left, visibility;

  .offcanvas-collapse {
/*   Adds a subtle drop shadow   */
    			-moz-background-clip: padding;     /* Firefox 3.6 */
			-webkit-background-clip: padding;  /* Safari 4? Chrome 6? */
			background-clip: padding-box;      /* Firefox 4, Safari 5, Opera 10, IE 9 */
    border-right:5px solid rgba(0, 0, 0, 0.2);

/* Makes the nav visibile with the open class */
  .offcanvas-collapse.open {
    left: 0;
    visibility: visible;

.navbar-expand-lg .navbar-nav {
    -ms-flex-direction: column;
    flex-direction: column;

.nav-scroller {
  position: relative;
  z-index: 2;
  height: 2.75rem;
  overflow-y: hidden;

.nav-scroller .nav {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
  padding-bottom: 1rem;
  margin-top: -1px;
  overflow-x: auto;
  color: rgba(255, 255, 255, .75);
  text-align: center;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;

.nav-underline .nav-link {
  padding-top: .75rem;
  padding-bottom: .75rem;
  font-size: .875rem;
  color: #6c757d;

.nav-underline .nav-link:hover {
  color: #007bff;

.nav-underline .active {
  font-weight: 500;
  color: #343a40;

              $(document).ready(function() {
 // executes when HTML-Document is loaded and DOM is ready
console.log("document is ready");
    $('[data-toggle="offcanvas"], #navToggle').on('click', function () {
// document ready  

window.onload = function() {
 // executes when complete page is fully loaded, including all frames, objects and images
console.log("window is loaded");
// window load  

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.