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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <nav id="menu" class="menu">
  <section class="menu-section">
    <h3 class="menu-section-title">Docs</h3>
    <ul class="menu-section-list">
      <li><a href="https://github.com/mango/slideout#installation" target="_blank">Installation</a></li>
      <li><a href="https://github.com/mango/slideout#usage" target="_blank">Usage</a></li>
      <li><a href="https://github.com/mango/slideout#api" target="_blank">API</a></li>
      <li><a href="https://github.com/mango/slideout#npm-scripts" target="_blank">npm-scripts</a></li>
    </ul>
  </section>

  <section class="menu-section">
    <h3 class="menu-section-title">Slideout</h3>
    <ul class="menu-section-list">
      <li><a href="https://github.com/mango/slideout" target="_blank">Fork it</a></li>
      <li><a href="https://github.com/mango/slideout/issues/new" target="_blank">Create an issue</a></li>
      <li><a href="https://github.com/mango/slideout/releases/">Download</a></li>
    </ul>
  </section>

  <section class="menu-section">
    <h3 class="menu-section-title">Mango</h3>
    <ul class="menu-section-list">
      <li><a href="https://getmango.com" target="_blank">About Mango</a></li>
      <li><a href="https://twitter.com/getmango" target="_blank">Follow Us</a></li>
    </ul>
  </section>
</nav>

<header class="fixed-header">
  <button class="btn-hamburger js-slideout-toggle"></button>
</header>
<main id="main" class="panel">  
  <header class="panel-header">
    <h1 class="title">Slideout.js</h1>
    <h2 class="subtitle">A touch slideout navigation menu for your mobile web apps.</h2>
    <div class="panel-actions">
      <a href="https://github.com/mango/slideout/releases/" class="btn btn-download">Download</a>
      <a href="https://github.com/mango/slideout" target="_blank" class="btn btn-fork">Fork it</a>
    </div>
  </header>

  <div class="panel-demo iphone">
    <img data-aload="assets/poster.png">
  </div>

  <section class="box">
    <h2 class="box-title">Features</h2>
    <div class="box-content">
      <ul>
        <li>Dependency-free.</li>
        <li>Simple markup.</li>
        <li>Native scrolling.</li>
        <li>Easy customization.</li>
        <li>CSS transforms &amp; transitions.</li>
        <li>Just 4 Kb!</li>
      </ul>
    </div>
  </section>

  <section class="box">
    <h2 class="box-title">Installation</h2>
    <div class="box-content">
      <pre>
$ npm install slideout

$ bower install https://github.com/mango/slideout.git

$ component install mango/slideout</pre>
    </div>
  </section>

  <section class="box">
    <h2 class="box-title">Usage</h2>
    <div class="box-content">
      <p>1. First of all, you'll need to have a menu ("#menu") and a main content ("#panel") into your body.</p>
      <pre><code class="language-markup">
&lt;nav id=&quot;menu&quot;&gt;
&lt;header&gt;
  &lt;h2&gt;Menu&lt;/h2&gt;
&lt;/header&gt;
&lt;/nav&gt;

&lt;main id=&quot;panel&quot;&gt;
&lt;header&gt;
  &lt;h2&gt;Panel&lt;/h2&gt;
&lt;/header&gt;
&lt;/main&gt;</code></pre>

      <p>2. Add the Slideout.js styles (index.css) in your web application.</p>
      <pre><code class="language-css">
body {
width: 100%;
height: 100%;
}

.slideout-menu {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 0;
width: 256px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
display: none;
}

.slideout-panel {
position: relative;
z-index: 1;
}

.slideout-open,
.slideout-open body,
.slideout-open .slideout-panel {
overflow: hidden;
}

.slideout-open .slideout-menu {
display: block;
}</code></pre>

      <p>3. Then you just include Slideout.js and create a new instace with some options:</p>

      <pre><code class="language-markup">
&lt;script src=&quot;dist/slideout.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
var slideout = new Slideout({
  'panel': document.getElementById('panel'),
  'menu': document.getElementById('menu'),
  'padding': 256,
  'tolerance': 70
});
&lt;/script&gt;</code></pre>
    </div>
  </section>

  <footer class="panel-footer">
    <p>with <span class="heart">❤</span> by <a href="https://getmango.com/en" target="_blank">Mango</a></p>
  </footer>
</main>
              
            
!

CSS

              
                .fixed-header {
  position: fixed;
  width: 100%;
  height: 50px;
  backface-visibility: hidden;
  z-index: 2;
  background-color: red;
}

.btn-hamburger {
  position: static;
  height: 40px;
  width: 40px;
}
              
            
!

JS

              
                var slideout = new Slideout({
  'panel': document.getElementById('main'),
  'menu': document.getElementById('menu'),
  'padding': 256,
  'tolerance': 70
});

document.querySelector('.js-slideout-toggle').addEventListener('click', function() {
  slideout.toggle();
});

var fixed = document.querySelector('.fixed-header');

slideout.on('translate', function(translated) {
  fixed.style.transform = 'translateX(' + translated + 'px)';
});

slideout.on('beforeopen', function () {
  fixed.style.transition = 'transform 300ms ease';
  fixed.style.transform = 'translateX(256px)';
});

slideout.on('beforeclose', function () {
  fixed.style.transition = 'transform 300ms ease';
  fixed.style.transform = 'translateX(0px)';
});

slideout.on('open', function () {
  fixed.style.transition = '';
});

slideout.on('close', function () {
  fixed.style.transition = '';
});
              
            
!
999px

Console