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

              
                <table class="c-bar-graph">
  <tfoot class="c-bar-graph__footer">
    <tr>
      <td>Apr 2015</td>
      <td>May 2015</td>
      <td>Jun 2015</td>
      <td>Jul 2015</td>
      <td>Aug 2015</td>
      <td>Sep 2015</td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td class="c-bar-graph__cell" data-graph="900">
        <span class="c-bar-graph__data">900</span>
      </td>
      <td class="c-bar-graph__cell" data-graph="1500">
        <span class="c-bar-graph__data">1500</span>
      </td>
      <td class="c-bar-graph__cell" data-graph="2400">
        <span class="c-bar-graph__data">2400</span>
      </td>
      <td class="c-bar-graph__cell" data-graph="3000">
        <span class="c-bar-graph__data">3000</span>
      </td>
      <td class="c-bar-graph__cell" data-graph="1200">
        <span class="c-bar-graph__data">1200</span>
      </td>
      <td class="c-bar-graph__cell" data-graph="1520">
        <span class="c-bar-graph__data">1520</span>
      </td>
    </tr>
  </tbody>
</table>
              
            
!

CSS

              
                body {
  padding: 10%;
  font-family: 'Montserrat', Helvetical, sans-serif;
  background: radial-gradient(100% 80%, #fff, #bbb);
}

// Table Stuff
.c-bar-graph {
  text-align: center;
  color: gray;
  font-size: .9rem;
  width: 100%;
  border-bottom: 1px solid lightgray;
  margin-bottom: 1rem;
  @media (min-width: 45em) {
    font-size: 1.1rem;
  }
  &__footer {
    border-top: 1px solid lightgray;
    td {
      line-height: 1.3em;
      font-size: 1.25rem;
      vertical-align: top;
      padding: .4rem 0;
      font-weight: 700;
    }
  }
  &__cell {
    height: 200px;
    vertical-align: bottom;
    padding-bottom: 0;
    color: white;
  }
  &__data {
    height: 30px;
    line-height: 30px;
    font-size: .9rem;
    display: block;
    margin: 0 10%;
    background: salmon linear-gradient(salmon 10px, tomato 100%);
    position: relative;
    transition: height 1s ease-out;
    transition-delay: 1s;
  }
  &__helper {
    font-weight: 400;
    font-size: 12px;
    line-height: 20px;
    clear: both;
    display: block;
    @media (min-width: 45em) {
      display: none;
    }
  }
}

              
            
!

JS

              
                let months = document.querySelectorAll('td');
const max = 5000;

months.forEach(month => {
  if (month.dataset.graph) {
    const value = month.dataset.graph;
    const bar = month.querySelector('span');
    const barHeight = (value / max) * 100;
    
    bar.style.height = `${barHeight}%`;
  }
});
              
            
!
999px

Console