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

+ add another resource


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


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.


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.


                - 1.upto(10) do |n|
      %h2= "small-block-grid-#{n}"
      - 1.upto(n*2) do |k|
        %h3= "&lt;li&gt; count: #{k}"
          - 1.upto(k) do|i|
              %p= "I am number #{i}"




                @import "compass/css3";

// This is just to make the Codepen results
// pretty, and layout well

// importing fonts
@import url(;
$body-font: "Source Sans Pro", sans-serif;

$body-background-color: #fff8f2;
$body-text-color: #ed815a;

$border-color-base-color: #edaa7d;
$border-color: rgba($border-color-base-color, 0.25);

$li-background-base-color: #c3ded9;
$li-background-color: rgba($li-background-base-color, .6);
$li-text-color: #566b69;

[class*="-block-grid-"] {
  > li {
    @include box-shadow(inset 0 0 0 2px $body-background-color);
    background: $li-background-color;
    color: $li-text-color;
    padding: 20px;

hr { border-color: $border-color; }

%text-base {
  font-weight: normal;
  line-height: 20px;
  margin-bottom: 4px;
  padding-top: 6px;
  padding-bottom: 10px;

body {
  background: $body-background-color;
  color: $body-text-color;

h2 {
  border-bottom: 2px solid $border-color;
  font-size: 20px;
  font-weight: 600;
  text-transform: uppercase;

h3 { font-size: 16px; }

body, h2, h3 {
  @extend %text-base;
  color: $body-text-color;
  font-family: $body-font;



                class Main
  constructor: ->

  pickHangers: ->
    $('ul[class*=-block-grid-').each (i, el) =>
      # define elements
      $ul = $(el)
      # we reverse this now to use later
      $lis = $ul.find('li')

      # string matching to get row count
      str = $ul.attr('class')
      re = /\w+\-block\-grid\-(\d+)\b/i
      rowCount = str.match(re)[1]

      # finding total length and remainders
      length = $lis.length
      remainder = length % rowCount

      if (remainder > 0)
        $liLastRow = $($lis.slice(-remainder))

        multiplier = rowCount - remainder
        width = @getWidthPercentage($lis, multiplier)
        $liLastRow.first().css("margin-left": "#{width}%")

  getWidthPercentage: ($el, n) ->
    width = $el.outerWidth()*n
    parentWidth = $el.parent().outerWidth()
    percent = 100*(width/parentWidth)/2
$(-> main = new Main())