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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <section class="document">
  <aside class="document__structure">
    <div class="document__area-header">
      <h3>Document structure</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
    </div>
    <div class="document__area-scroller"> 
      <nav role="navigation">
        <ul>
          <li><a href="#">TOC</a></li>
          <li><a href="#">Chapter 1</a></li>
          <li><a href="#">Chapter 2</a></li>
          <li><a href="#">Chapter 3</a></li>
          <li><a href="#">Chapter 4</a></li>
          <li><a href="#">Chapter 5</a></li>
        </ul>
      </nav>
    </div>
  </aside>
  <main class="document__content">
    <div class="document__area-header">
      <h3>Document content</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem quas, omnis mollitia, neque reiciendis veritatis quasi, libero.</p>
    </div>
    <div class="document__area-scroller">
      <div class="document__blocks">
        <div class="document__block--item">
          <h1>TOC</h1>
          <ol>
            <li>Chapter 1</li>
            <li>Chapter 2</li>
            <li>Chapter 3</li>
            <li>Chapter 4</li>
            <li>Chapter 5</li>
          </ol>
        </div>
        <div class="document__block--item active">
          <h2>Chapter 1</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam ab ex aliquam aliquid natus quibusdam molestias earum assumenda illum, porro voluptates, harum dolores in libero accusamus voluptatem modi vero. Placeat.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi id in vitae modi voluptatibus nihil, sint. Cum autem beatae quaerat rem minima est culpa quo quos temporibus aperiam dolorem, incidunt?</p>
        </div>
        <div class="document__block--item">
          <h2>Chapter 2</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam ab ex aliquam aliquid natus quibusdam molestias earum assumenda illum, porro voluptates, harum dolores in libero accusamus voluptatem modi vero. Placeat.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi id in vitae modi voluptatibus nihil, sint. Cum autem beatae quaerat rem minima est culpa quo quos temporibus aperiam dolorem, incidunt?</p>
        </div>
        <div class="document__block--item">
          <h2>Chapter 3</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam ab ex aliquam aliquid natus quibusdam molestias earum assumenda illum, porro voluptates, harum dolores in libero accusamus voluptatem modi vero. Placeat.</p>
          <p><img src="https://placeimg.com/640/320/arch/grayscale" alt="Building" /></p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi id in vitae modi voluptatibus nihil, sint. Cum autem beatae quaerat rem minima est culpa quo quos temporibus aperiam dolorem, incidunt?</p>
        </div>
        <div class="document__block--item">
          <h2>Chapter 4</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam ab ex aliquam aliquid natus quibusdam molestias earum assumenda illum, porro voluptates, harum dolores in libero accusamus voluptatem modi vero. Placeat.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi id in vitae modi voluptatibus nihil, sint. Cum autem beatae quaerat rem minima est culpa quo quos temporibus aperiam dolorem, incidunt?</p>
        </div>
        <div class="document__block--item">
          <h2>Chapter 5</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam ab ex aliquam aliquid natus quibusdam molestias earum assumenda illum, porro voluptates, harum dolores in libero accusamus voluptatem modi vero. Placeat.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi id in vitae modi voluptatibus nihil, sint. Cum autem beatae quaerat rem minima est culpa quo quos temporibus aperiam dolorem, incidunt?</p>
        </div>
      </div>
    </div>
  </main>
  <aside class="document__collaboration">
    <div class="document__area-header">
      <h3>Document comments</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit perspiciatis laboriosam sit est quod.</p>
    </div>
    <div class="document__area-scroller"> 
      <ul class="document__comments">
        <li>
          <div class="document__comments--item author">
            <div class="comment__avatar">
              <img src="https://s3.amazonaws.com/uifaces/faces/twitter/dancounsell/128.jpg" alt="John Doe" />
            </div>
            <div class="comment__meta-data">
              <div class="author-name">John Doe</div>
              <div class="date-posted">2017-01-02 @ 12:34</div>
            </div>
            <div class="comment__actions">
              <a href="#" class="remove">Remove</a>
              <a href="#" class="edit">Edit</a>
            </div>
            <div class="comment__content">
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis nostrum, minima minus deleniti corrupti voluptatem quis animi! Maiores molestias blanditiis harum itaque eos architecto corporis doloribus ut, fugiat, perspiciatis nobis.</p>
            </div>
          </div>
        </li>
        <li>
          <div class="document__comments--item respondent">
            <div class="comment__avatar">
              <img src="https://s3.amazonaws.com/uifaces/faces/twitter/brad_frost/128.jpg" alt="John Doe" />
            </div>
            <div class="comment__meta-data">
              <div class="author-name">Jimmy Doe</div>
              <div class="date-posted">2017-01-02 @ 13:57</div>
            </div>
            <div class="comment__actions disabled">
              <a href="#" class="remove">Remove</a>
              <a href="#" class="edit">Edit</a>
            </div>
            <div class="comment__content">
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit ipsum dolore eveniet nam illo dolorum, temporibus inventore quis a illum. Ipsum, minus maxime, impedit numquam facilis quas vitae molestiae debitis.</p>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </aside>
</section>
              
            
!

CSS

              
                $aside-width: 25%;
$avatar-size: 48px;

$teal--0: #009494;

@import url('https://fonts.googleapis.com/css?family=Roboto');

* {
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}

/*                   1
 *    _______________________________
 *   | _____ | _____________ | _____ |
 *   ||     |||             |||     ||
 *   ||  2  |||      3      |||  4  ||
 *   ||     |||             |||     ||
 *   ||_____|||_____________|||_____||
 *   |_______|_______________|_______|
 *
 *   1 = .document
 *   2 = .document__structure
 *   3 = .document__content
 *   4 = .document__collaboration
 *
 *****************************************/

/* 1. 
 * Document should occupy the entire
 * viewport width available.
 *****************************************/
.document {
  // flex stuff
  display: flex;
  flex-direction: row;
  
  margin: 1em;
}

/* 2 & 4.
 * Structure and Collaboration columns 
 * should have a set width.
 *****************************************/
.document__structure, 
.document__collaboration {
  // flex stuff
  display: flex;
  flex-direction: column;
  
  width: $aside-width;
}

/* 3.
 * Content column should be automatically
 * adjusted based on the viewport width 
 * available.
 *****************************************/
.document__content {
  // flex stuff
  display: flex;
  flex-direction: column;
  
  //background-color: #E03616;
  margin: 0 1em;
}

/*       2
 *    _______
 *   | _____ |
 *   ||  5  ||
 *   ||_____||
 *   ||     ||
 *   ||     ||
 *   ||  6  ||
 *   ||     ||
 *   ||_____||
 *   |_______|
 *
 *   2 = .document__structure
 *   5 = .document__area-header
 *   6 = .document__area-scroller
 *
 *****************************************/

/* 5.
 * Same height across all three instances, 
 * regardless of content, based on the 
 * height of the most content in a header
 * area.
 *****************************************/
.document__area-header {
  // flex stuff
  
  background-color: $teal--0;
  color: #fff;
  padding: 1em;
  
  h3 {
    margin: 0;
  }
  
  p {
    font-size: 90%;
    margin: 1em 0 0;
  }
}

/* 6.
 * Same height across all three instances, 
 * regardless of content, based on the 
 * most content in a scrollable area.
 *****************************************/
.document__area-scroller {
  // flex stuff
  
  border-bottom: 3px solid $teal--0;
  height: 400px;
  overflow-y: auto;
}

.document__collaboration {
  .document__area-scroller {
    padding: 0 1em 0 0;
  }
}

/* I don't foresee any Flexbox stuff after
 * the above classes.
 *****************************************/

.document__block--item {
  border-top: 1px dotted rgba($teal--0, .25);
  padding: 0.5em 1em;
  
  &.active {
    background: rgba($teal--0, .05);
    box-shadow: 0 0 (1em) rgba($teal--0, .33);
  }
}

.document__comments {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.document__comments--item {
  padding: 1em 0;
  
  &.author,
  &.respondent {
    border-left: 4px solid $teal--0;
    padding-left: 1em;
  }
  
  &.respondent {
    border-color: rgba($teal--0, .25);
    border-width: 8px;
    padding-left: 1.5em;
  }
  
  .comment__avatar {
    float: left;
    
    img {
      height: $avatar-size;
      width: $avatar-size;
    }
  }
  
  .comment__meta-data,
  .comment__actions {
    margin-left: ($avatar-size + 8);
  }
  
  .date-posted {
    font-size: 80%;
  }
  
  .comment__actions {
    &.disabled {
      a {
        color: #ddd;
        cursor: not-allowed;
      }
    }
    
    a {
      text-decoration: none;
    }
  }
  
  .comment__content {
    p:last-of-type {
      margin-bottom: 0;
    }
  }
}
              
            
!

JS

              
                // all elems same height, vanilla version
// https://codepen.io/gabssnake/pen/vEEewX

function sameHeights () {

  var nodeList = document.querySelectorAll('.document__area-header');
  var elems = [].slice.call(nodeList);

  var tallest = Math.max.apply(Math, elems.map(function(elem, index) {
    elem.style.minHeight = ''; // clean first
    return elem.offsetHeight;
  }));

  elems.forEach(function(elem, index, arr){ 
    elem.style.minHeight = tallest + 'px';
  });
  
}

var resized = true;
var timeout = null;

var refresh = function(){
  if(resized) {
    requestAnimationFrame(sameHeights);
  }
	clearTimeout(timeout);
	timeout = setTimeout( refresh, 100);
  resized = false;
};

window.addEventListener('resize', function() { resized = true; });

refresh();

              
            
!
999px

Console