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.

            
              <div class="wrapper">
  <a href="javascript:void(0);" class="toggle rgba"></a>
  <div class="red">
    <ul>
      <li>10%</li>
      <li>20%</li>
      <li>30%</li>
      <li>40%</li>
      <li>50%</li>
      <li>60%</li>
      <li>70%</li>
      <li>80%</li>
      <li>90%</li>
      <li>100%</li>
    </ul>
  </div>

  <div class="green">
    <ul>
      <li>10%</li>
      <li>20%</li>
      <li>30%</li>
      <li>40%</li>
      <li>50%</li>
      <li>60%</li>
      <li>70%</li>
      <li>80%</li>
      <li>90%</li>
      <li>100%</li>
    </ul>
  </div>

  <div class="blue">
    <ul>
      <li>10%</li>
      <li>20%</li>
      <li>30%</li>
      <li>40%</li>
      <li>50%</li>
      <li>60%</li>
      <li>70%</li>
      <li>80%</li>
      <li>90%</li>
      <li>100%</li>
    </ul>
  </div>
</div>
            
          
!
            
              /*
// ALPHA MIXIN - PARAMATERS

$color - Required
Foreground color that are wanting to become semi-transparent and to which provide a hex fallback for.

$alpha - Optional
Transparency amount of foreground color, as a percentage inc % unit. Defaults to 50%.

$bgcolor - Optional but highly recomended
Color that appears behind the semi-transparent foreground color. Defaults to white.

$property - Optional
Which CSS property the semi-transparent color is to be applied to. Defaults to background-color.

*/


@mixin alpha($color, $alpha: 50%, $bgcolor: #fff, $property: background-color) {
  // Opacify any rgba value that may be passed through
  $color-hex: opacify($color, 1);
  $bgcolor-hex: opacify($bgcolor, 1);
  // Set max and min percentages to avoid errors
  @if $alpha > 100% { $alpha: 100%; }
  @if $alpha < 0% { $alpha: 0%; }
  // Creates decimal version of percentage value stripping unit and dividing by 100
  $decimal: ($alpha / ($alpha * 0 + 1) / 100);

  // Creates styles outputting: 
  // - Property Name - default background-color
  // - Fallback style with Hex value
  // - Proper style with RGBA value
  #{$property}: mix($color-hex,$bgcolor-hex, $alpha);
  #{$property}: rgba($color-hex, $decimal);
  
  
  //REMOVE THIS - JUST FOR EXAMPLE TO SHOW HEX VALUES IS RBGA COMPATIBILE BROWSER...
  .ie8 & {
    #{$property}: mix($color-hex,$bgcolor-hex, $alpha);
  }
  //END OF SECTION TO BE REMOVED
}

.red {
  background: #aaa;
}

@for $i from 1 through 10 {
  .red li:nth-child(#{$i}) {
    @include alpha($color: red, $bgcolor: #aaa, $alpha: ($i * 10%));
  }
}

.blue {
  background: #aaa;
}

@for $i from 1 through 10 {
  .blue li:nth-child(#{$i}) {
    @include alpha($color: blue, $bgcolor: #aaa, $alpha: ($i * 10%));
  }
}

.green {
  background: #aaa;
}

@for $i from 1 through 10 {
  .green li:nth-child(#{$i}) {
    @include alpha($color: green, $bgcolor: #aaa, $alpha: ($i * 10%));
  }
}





body, html{
  background: #f6f0ee;
}

* {
  box-sizing: border-box;
}
div {
  overflow: hidden;
  margin-bottom: 20px;
}

ul,li {
  margin: 0;
  list-style: none;
}

ul {
  //margin: 20px;
  overflow: hidden;
  padding: 20px;
}

li {
  width: 20%;
  text-align: center;
  padding: 20px 0;
  float: left;
  color: white;
}

.toggle {
  background: black;
  padding: 10px; 
  display: block;
  text-align: center; 
  border-bottom: 2px #666 solid;
  border-radius: 5px;
  text-decoration: none;
  color: white;
  margin-bottom: 20px;
  cursor: pointer;
  &:hover{
    background: #333;
  }
  &.hex:before {
    content: 'View with RGBA Values';
  }
  &.rgba:before {
    content: 'View with Hex Values';
  } 
}
            
          
!
            
              jQuery(document).ready(function($){	
  $('.toggle').click(function(){
    $(this).toggleClass('hex').toggleClass('rgba');
    $('.wrapper').toggleClass('ie8');
    //colorValue();
  });
}); 

  


function colorValue() {
  $('li').each(function(){
    var color = $(this).css('background-color');
    alert(color);
    $(this).text(color);
  });
}
            
          
!
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