cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

              - 1.upto(10) do |n|
      %h2= "small-block-grid-#{n}"
      - 1.upto(n*2) do |k|
        %h3= "<li> 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(https://fonts.googleapis.com/css?family=Source+Sans+Pro);
$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())
Loading ..................