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 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.

Quick-add: + add another resource

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.

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= "&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(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 ..................