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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console