cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-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.

            
              .wrapper
  %h1
    Embedding icons from Font Awesome
  %p
    Sometimes you will need to have icons only when an event is triggered. You might use an empty element to do that, this mixin is to avoid the use of that technique.
.wrapper 
  %h2
    &:before
  - @menuItems = ['Date (Old)','Date (New)','Name (A-Z)','Name (Z-A)']
  %ul.list
    - @menuItems.each do |item|
      %li.list-item
        %a.list-item__lnk.-thm-1.js-active{:href=>"#"}
          #{item}
.wrapper
  %h2
    &:after
    %ul.list
      - @menuItems.each do |item|
        %li.list-item
          %a.list-item__lnk.-thm-2.js-active{:href=>"#"}
            #{item}
            
          
!
            
              $pull-unit: 1.1rem;

@mixin embed-icon($code_icon, $fontSize:auto, $color: inherit, $position: before){
  @if($code_icon == ""){
    $code_icon:  'No icon defined';
    $color: red;
  }
  //The styles from FontAwesome
  display: inline-block;
  font-family: FontAwesome;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  &:#{$position}{  
    position: relative;
    content:'#{$code_icon}';
    font-size: $fontSize;
    color: $color;
    margin-left: -($pull-unit);//Pull the icon
    @if ($position == after){
      margin-left: 0;
    }
  }
}


body {
  background: #f3f3f3;
  font-family: 'Open Sans', sans-serif;
}
.wrapper{
  width: 500px;
  margin: 10px auto;
  padding: 1rem;
  > h1{
    font-size: 1.3rem;
    line-height: 2rem;
  }
  > p{
    font-size: .9rem;
    line-height: 1.2rem;
    color: grey;
  }
}
.list{
  width: 100%;
  margin:  1rem auto;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.list-item{
  padding: .5rem 1rem;
}
.list-item__lnk{
  position: relative;
  text-decoration: none;
  font-size: .9rem;
  color: grey;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;

  &.-thm-1{
    margin-left: $pull-unit;//Leaving space for icon
    &.-current{
      @include embed-icon('\f00c', 1em, green, before);
    }
  }
  &.-thm-2{
    &.-current{
      @include embed-icon('\f00a', 1em, orange, after);
    }
  }
}



            
          
!
            
              $('.js-active').on 'click', (e)->
  e.preventDefault()
  $('.js-active').removeClass '-current'
  $(@).addClass '-current'
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console