Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="header"></div>
              
            
!

CSS

              
                // LessHat Lib
// Config supported browsers for your project

    @w3c: true; // Unprefixed W3C syntax
    @webkit: true; // Chrome 7+, Safari 5+, iOS5, Android
    @moz: true; //  Firefox 4+
    @opera: true; // Opera 10.5+
    @ms: true;  // IE 10+

  // Signals

    @webkitSignal: 1;
    @mozSignal: 2;
    @operaSignal: 3;
    @msSignal: 4;
    @w3cSignal: 5;

  .transform(@arguments:none, ...){

      //  Local config for disabling properties

      @w3cLocal: true; // Unprefixed W3C syntax
      @webkitLocal: true; // Chrome 7+, Safari 5+, iOS5, Android
      @mozLocal: true; //  Firefox 4+
      @operaLocal: true; // Opera 10.5+
      @msLocal: true;  // IE 10+

      .result (@arguments, @signal, @boolean, @localBoolean) when (@boolean = true) and (@localBoolean = true) {
        .inception (@signal, @arguments) when (@signal = 1) { -webkit-transform: @arguments;}
        .inception (@signal, @arguments) when (@signal = 2) { -moz-transform: @arguments;}
        .inception (@signal, @arguments) when (@signal = 3) { -o-transform: @arguments;}
        .inception (@signal, @arguments) when (@signal = 4) { -ms-transform: @arguments;}
        .inception (@signal, @arguments) when (@signal = 5) { transform: @arguments;}
        .inception (@signal, @arguments) when (@signal > 5),(@signal < 1) { error: "Signal is out of range"; }
        .inception(@signal, @arguments);
      }
      .result (@arguments, @signal, @boolean, @localBoolean) when not (@boolean = true), not (@localBoolean = true) { }

      .result(@arguments, @webkitSignal, @webkit, @webkitLocal);
      // --  this comment must be here because of LESS bug
      .result(@arguments, @mozSignal, @moz, @mozLocal);
      // --
      .result(@arguments, @operaSignal, @opera, @operaLocal);
      // --
      .result(@arguments, @msSignal, @ms, @msLocal);
      // --
      .result(@arguments, @w3cSignal, @w3c, @w3cLocal);
  }


.gradient(...){

      //  Local config for disabling properties

      @svg: true; //  SVG gradient for IE9
      @mozLocal: true; //  Firefox 4+
      @webkitLocal: true; // Chrome 7+, Safari 5+, iOS5, Android
      @operaLocal: true; // Opera 10.5+
      @w3cLocal: true; // Unprefixed W3C syntax
      
      @backgroundSVG: ~`(function(){function G(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c,d,e,f,g,h,i,j,k=0,l=0,m="",n=[];if(!a)return a;do c=a.charCodeAt(k++),d=a.charCodeAt(k++),e=a.charCodeAt(k++),j=c<<16|d<<8|e,f=j>>18&63,g=j>>12&63,h=j>>6&63,i=j&63,n[l++]=b.charAt(f)+b.charAt(g)+b.charAt(h)+b.charAt(i);while(k<a.length);m=n.join("");var o=a.length%3;return(o?m.slice(0,o-3):m)+"===".slice(o||3)}var a="@{arguments}",b=null,c=!0,d=a.split(/,(?=\s*(?:linear|radial))/g),e=d.length,f=/top/,g=/right/,h=/bottom/,i=/left/,j=/to\s*top/,k=/to\s*right/,l=/to\s*bottom/,m=/to\s*left/,n=/45deg/,o=/-45deg/,p=/\d*deg/;for(var q=0;q<e;q++){if(/linear/.test(d[q])){d[q]=d[q].replace(/linear-gradient\s*\(/,'<?xml version="1.0" ?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">');if(f.test(d[q])&&!j.test(d[q])||l.test(d[q])||/180deg/.test(d[q])){var r=null;l.test(d[q])?r=l:/180deg/.test(d[q])?r=/180deg/:r=f,d[q]=d[q].replace(r,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%">')}else if(g.test(d[q])&&!k.test(d[q])||m.test(d[q])||/270deg/.test(d[q])){var r=null;m.test(d[q])?r=m:/270deg/.test(d[q])?r=/270deg/:r=g,d[q]=d[q].replace(r,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="100%" y1="0%" x2="0%" y2="0%">')}else if(h.test(d[q])&&!l.test(d[q])||j.test(d[q])||/[^\d]0deg/.test(d[q])){var r=null;j.test(d[q])?r=j:/0deg/.test(d[q])?r=/0deg/:r=h,d[q]=d[q].replace(r,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="100%" x2="0%" y2="0%">')}else if(i.test(d[q])&&!m.test(d[q])||k.test(d[q])||/90deg/.test(d[q])){var r=null;k.test(d[q])?r=k:/90deg/.test(d[q])?r=/90deg/:r=i,d[q]=d[q].replace(r,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="100%" y2="0%">')}else n.test(d[q])&&!o.test(d[q])?d[q]=d[q].replace(n,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="100%" x2="100%" y2="0%">'):o.test(d[q])?d[q]=d[q].replace(o,'<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="100%" y2="100%">'):c=!1}try{"".trim(),b=!0}catch(s){b=!1}b&&(d[q]=d[q].trim());if(/linear/.test(d[q])||/radial/.test(d[q])){d[q]=d[q].slice(0,-1),d[q]="url(data:image/svg+xml;base64--"+d[q]+'</linearGradient><rect x="0" y="0" width="1" height="1" fill="url(***)" /></svg>)';var t=d.join("@@@"),u=t.match(/rgba?\(\d+,\s*\d+,\s*\d+,\s*(?:0|1|\.\d+|0\.\d+)\)\s*\d*%*/g)||0,v=t.match(/hsla?\(\d+,\s*\d+%,\s*\d+%,\s*(?:0|1|\.\d+|0\.\d+)\)\s*\d*%*/g)||0,w=[],x=[];for(var y=0;y<u.length;y++)w[y]=u[y].replace(/,/g,"--");for(var z=0;z<v.length;z++)x[z]=v[z].replace(/,/g,"--");for(var A=0;A<u.length;A++)t=t.replace(u[A],w[A]);for(var B=0;B<v.length;B++)t=t.replace(v[B],x[B]);var C=t.split(",");for(var D=0;D<C.length;D++){C[D]=C[D].replace(/(#\w{3,6})\s*(\d*%*)/g,'<stop offset="$2" stop-color="$1" stop-opacity="1"/>').replace(/(rgba?\(\d+--\s*\d+--\s*\d+--\s*(0|1|\.\d+|0\.\d+)\))\s*(\d*%)*/g,'<stop offset="$3" stop-color="$1" stop-opacity="$2"/>').replace(/rgba/g,"rgb").replace(/(hsla?\(\d+--\s*\d+%--\s*\d+%--\s*(0|1|\.\d+|0\.\d+)\))\s*(\d*%)*/g,'<stop offset="$3" stop-color="$1" stop-opacity="$2"/>').replace(/hsla/g,"hsl").replace(/((?:aqua|black|blue|fuchsia|gray|grey|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow))\s*(\d*%)*/g,'<stop offset="$2" stop-color="$1" stop-opacity="1"/>').replace(/\*\*\*/,"#grad-ucgg-generated");try{"".trim(),b=!0}catch(s){b=!1}b&&(C[D]=C[D].trim())}C=C.toString().replace(/,/g,"").replace(/--/g,",").replace(/(rgb?\(\d+,\s*\d+,\s*\d+),\s*(?:0|1|\.\d+|0\.\d+)\)/g,"$1)").replace(/(hsl?\(\d+,\s*\d+%,\s*\d+%),\s*(?:0|1|\.\d+|0\.\d+)\)/g,"$1)")}}/radial/.test(C)&&(/((ellipse).*(center)|(circle).*(center))/g.test(C)?C=C.replace(/<\/linearGradient>/g,"</radialGradient>").replace(/radial-gradient[^<]+/g,'<?xml version="1.0" ?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none"><radialGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" cx="50%" cy="50%" r="75%">').replace(/<rect x=\S+\d\S+ y=\S+\d\S+ width=\S+\d\S+ height=\S+\d\S+ fill=\S+\w\S+ \/>/g,'<rect x="-50" y="-50" width="101" height="101" fill="url(#grad-ucgg-generated)" />'):C=!1);var E=null;try{C=C.split("@@@");var F=0;for(F;F<C.length;F++)E=C[F].match(/<\?xml.*<\/svg>/),E=G(E.join("")),C[F]=C[F].replace(/(<\?xml.*<\/svg>)/,E)}catch(s){}return c?C:C=!1,C?C.toString().replace(/\[/g,"").replace(/\]/g,""):C}())`;
      @backgroundMoz: ~`(function(){var a,b,c,d,e,f,g,h,i,j,k;a="@{arguments}",c=null,d=a.split(/,(?=\s*(?:linear|radial))/g),e=d.length,k=/to\s*top/,j=/to\s*right/,h=/to\s*bottom/,i=/to\s*left/,b=/\d*deg/,f=0;while(f<e){/linear/.test(d[f])?(d[f]=d[f].replace(/linear-gradient/,"-moz-linear-gradient"),k.test(d[f])?d[f]=d[f].replace(k,"bottom"):j.test(d[f])?d[f]=d[f].replace(j,"left"):h.test(d[f])?d[f]=d[f].replace(h,"top"):i.test(d[f])?d[f]=d[f].replace(i,"right"):b.test(d[f])&&(g=d[f].match(/\d*deg/),g=(parseInt(g)-90)*-1+"deg",d[f]=d[f].replace(b,g))):d[f]=d[f].replace(/radial-gradient/,"-moz-radial-gradient").replace(/,\s* \d*(px|%) \d*(px|%)/,", circle").replace(/\(+\s*(.*) at\s*([^,]+)/g,"($2, $1");try{"".trim(),c=!0}catch(l){c=!1}c&&(d[f]=d[f].trim()),f++}return d.toString().replace(/\[/g,"").replace(/\]/g,"");}())`;
      @backgroundWebkit: ~`(function(){var a,b,c,d,e,f,g,h,i,j,k;a="@{arguments}",c=null,d=a.split(/,(?=\s*(?:linear|radial))/g),e=d.length,k=/to\s*top/,j=/to\s*right/,h=/to\s*bottom/,i=/to\s*left/,b=/\d*deg/,f=0;while(f<e){/linear/.test(d[f])?(d[f]=d[f].replace(/linear-gradient/,"-webkit-linear-gradient"),k.test(d[f])?d[f]=d[f].replace(k,"bottom"):j.test(d[f])?d[f]=d[f].replace(j,"left"):h.test(d[f])?d[f]=d[f].replace(h,"top"):i.test(d[f])?d[f]=d[f].replace(i,"right"):b.test(d[f])&&(g=d[f].match(/\d*deg/),g=(parseInt(g)-90)*-1+"deg",d[f]=d[f].replace(b,g))):d[f]=d[f].replace(/radial-gradient/,"-webkit-radial-gradient").replace(/\(+\s*(.*) at\s*([^,]+)/g,"($2, $1");try{"".trim(),c=!0}catch(l){c=!1}c&&(d[f]=d[f].trim()),f++}return d.toString().replace(/\[/g,"").replace(/\]/g,"");}())`;
      @backgroundOpera: ~`(function(){var a,b,c,d,e,f,g,h,i,j,k;a="@{arguments}",c=null,d=a.split(/,(?=\s*(?:linear|radial))/g),e=d.length,k=/to\s*top/,j=/to\s*right/,h=/to\s*bottom/,i=/to\s*left/,b=/\d*deg/,f=0;while(f<e){/linear/.test(d[f])?(d[f]=d[f].replace(/linear-gradient/,"-o-linear-gradient"),k.test(d[f])?d[f]=d[f].replace(k,"bottom"):j.test(d[f])?d[f]=d[f].replace(j,"left"):h.test(d[f])?d[f]=d[f].replace(h,"top"):i.test(d[f])?d[f]=d[f].replace(i,"right"):b.test(d[f])&&(g=d[f].match(/\d*deg/),g=(parseInt(g)-90)*-1+"deg",d[f]=d[f].replace(b,g))):d[f]=d[f].replace(/radial-gradient/,"-o-radial-gradient").replace(/\(+\s*(.*) at\s*([^,]+)/g,"($2, $1");try{"".trim(),c=!0}catch(l){c=!1}c&&(d[f]=d[f].trim()),f++}return d.toString().replace(/\[/g,"").replace(/\]/g,"");})()`;
      @backgroundW3C: ~`(function(){var a,b,c,d,e;a="@{arguments}",b=null,c=a.split(/,(?=\s*(?:linear|radial))/g),d=c.length,e=0;while(e<d){try{"".trim(),b=!0}catch(f){b=!1}b&&(c[e]=c[e].trim()),e++}return c.toString().replace(/\[/g,"").replace(/\]/g,"");}())`;

      .result(@arguments, @boolean, @localBoolean) when (@boolean = true) and (@localBoolean = true) { background-image: @arguments; }
      .result(@arguments, @boolean, @localBoolean) when not (@boolean = true), not (@localBoolean = true) { }
      .result(@arguments, @boolean, @localBoolean, @property) when (@boolean = true) and (@localBoolean = true) and (isstring(@property)) { background-image: @arguments; }
      .result(@arguments, @boolean, @localBoolean, @property) when not (@boolean = true), not (@localBoolean = true), not (isstring(@property)) { }

      .result(@backgroundSVG, @svg, @svg, @backgroundSVG);
      // --  this comment must be here because of LESS bug
      .result(@backgroundMoz, @moz, @mozLocal);
      // --
      .result(@backgroundWebkit, @webkit, @webkitLocal);
      // --
      .result(@backgroundOpera, @opera, @operaLocal);
      // --
      .result(@backgroundW3C, @w3c, @w3cLocal);
  }


html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  background: #fff;
  font-size: 1em;
  font-family: "Segoe WP Light", "OpenSansLight", sans-serif;
  -webkit-font-smoothing: subpixel-antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Segoe WP", "OpenSansRegular", sans-serif;
  font-weight: normal;
}

.container {
  width: 100%;
  height: 100%;
}

.header {
  width: 100%;
  height: 100%;
  float: left;
  position: relative;
  overflow: hidden;
  background: #6acda7;
  .gradient(~"linear-gradient(-180deg, #21845e 0%, #092a19 100%)");
  .transform(translateZ(0));
  -webkit-perspective: 1000;
  -webkit-backface-visibility: hidden;
}

.header .logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 271px;
  height: 344px;
  background-size: 271px 344px;
  margin-left: -135px;
  margin-top: -172px;
  .transform(translateZ(0));
  -webkit-perspective: 1000;
  -webkit-backface-visibility: hidden;
  background: url(../images/logo.png) no-repeat;
  z-index: 31;
}

.header .particle {
  opacity: 0;
  position: absolute;
  background: #6acda7;
  .transform(translateZ(0));
  -webkit-perspective: 1000;
}
              
            
!

JS

              
                /*
  Copyright John Josef | uh-sem-blee, Co. | typefoo
*/
function ParticleModel(config) {
      var $scope = this;
      var MAX_SIZE = 200;
      var MIN_SIZE = 20;
      var MAX_SPEED = 30; // per second
      var MIN_SPEED = 2;
      var MAX_OPACITY = 0.5;
      var MIN_OPACITY = 0.2;
      var MAX_VECTOR = 360;
      var MIN_VECTOR = 0;
      var MAX_LIFE = 20000; // ms
      var MIN_LIFE = 5000;
      
      var defaults = {
        displayed: false,
        ended: false,
        size: 0,
        x: 0,
        y: 0,
        speed: 0,
        opacity: 1,
        vector: 0,
        domElement: angular.element(document.createElement('div')).addClass('particle'),
        id: undefined,                  // should be defined in config
        boxSize: {width: 0, height: 0}, // should be defined in config
        header: undefined,              // should be defined in config
        controller: undefined           // should be defined in config
      };
      
      $scope.config = angular.extend(defaults, config);
    
      var rand_range = function(min, max, round) {
        if(round === undefined) {
          return Math.floor(Math.random() * (max - min) + min);
        } else if (round === false) {
          return Math.random() * (max - min) + min;
        }
      };
      
      $scope.init = function() {
        $scope.config.size = rand_range(MIN_SIZE, MAX_SIZE);
        $scope.config.speed = rand_range(MIN_SPEED, MAX_SPEED);
        $scope.config.x = rand_range(0, $scope.config.boxSize.width);
        $scope.config.y = rand_range(0, $scope.config.boxSize.height);
        $scope.config.opacity = rand_range(MIN_OPACITY, MAX_OPACITY, false);
        if($scope.config.size > 100) {
          $scope.config.opacity = rand_range(0.01, 0.2, false);
        }
        $scope.config.blur = $scope.config.size / 8;
        $scope.config.vector = rand_range(MIN_VECTOR, MAX_VECTOR);
        $scope.config.xspeed = Math.cos($scope.config.vector) * $scope.config.speed;
        $scope.config.yspeed = Math.sin($scope.config.vector) * $scope.config.speed;
        var createTime = new Date().getTime();
        var expires = new Date().getTime() + rand_range(MIN_LIFE, MAX_LIFE);
        $scope.config.life = expires - createTime;
        
        function particleEnd() {
          if($scope.config.displayed === false) {
            $scope.config.displayed = true;
            return;
          }
          if($scope.config.ended === false) {
            $scope.config.domElement.css({
              transition: 'opacity 1s linear',
              WebkitTransition: 'opacity 1s linear',
              MozTransition: 'opacity 1s linear',
            });
            var style1 = document.querySelector('style#style-' + $scope.config.id);
            style1.innerHTML = '.animated-' + $scope.config.id + ' { opacity: 0 !important; transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) !important; -webkit-transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) !important; -moz-transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) !important; }';
            $scope.config.ended = true;
            return;
          }
          
          var style = document.querySelector('style#style-' + $scope.config.id);
          document.getElementsByTagName('head')[0].removeChild(style);
          $scope.config.ended = true;
          
          $scope.config.domElement[0].parentNode.removeChild($scope.config.domElement[0]);
          
          var p = new ParticleModel({
            id: $scope.config.controller.numParticles,
            boxSize: {
              width: $scope.config.header[0].offsetWidth,
              height: $scope.config.header[0].offsetHeight
            },
            header: $scope.config.header,
            controller: $scope.config.controller
          }).init();
          
          $scope.config.controller.numParticles++;
          $scope.config.header.append(p.config.domElement);
        }
        
        $scope.config.domElement[0].addEventListener('webkitTransitionEnd', particleEnd);
        $scope.config.domElement[0].addEventListener('transitionend', particleEnd);
        
        $scope.updateDOMStyles();
    
        $scope.config.x += Math.floor($scope.config.xspeed * $scope.config.life / 1000);
        $scope.config.y += Math.floor($scope.config.yspeed * $scope.config.life / 1000);
    
        $scope.updateXY();
        
        return $scope;
      };
      
      $scope.updateDOMStyles = function() {
        $scope.config.domElement.css({
          width: $scope.config.size + 'px',
          height: $scope.config.size + 'px',
          borderRadius: $scope.config.size/2 + 'px',
          webkitFilter: 'blur(' + $scope.config.blur + 'px)',
          filter: 'blur(' + $scope.config.blur + 'px)',
          transition: 'transform ' + $scope.config.life/1000 + 's linear, opacity 1s linear',
          WebkitTransition: '-webkit-transform ' + $scope.config.life/1000 + 's linear, opacity 1s linear',
          MozTransition: '-moz-transform ' + $scope.config.life/1000 + 's linear, opacity 1s linear',
          transform: 'translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1)',
          webkitTransform: 'translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1)',
          MozTransform: 'translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1)'
        });
      };
      
      $scope.updateXY = function() {
        var className = 'animated-' + $scope.config.id;
        var style = document.createElement('style');
        style.type = 'text/css';
        style.id = 'style-' + $scope.config.id;
        style.innerHTML = '.' + className + ' { opacity: ' + $scope.config.opacity + ' !important; transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1) !important; -webkit-transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1) !important; -moz-transform: translate3d(' + $scope.config.x + 'px, ' + $scope.config.y + 'px, 0px) scale3d(1,1,1) !important; }';
        document.getElementsByTagName('head')[0].appendChild(style);
        setTimeout(function() {
          $scope.config.domElement.addClass(className);
        }, 100);
      };
      
      return $scope;
    }
    
    function ParticleController(config) {
      var $scope = this;
      $scope.numParticles = 0;
      
      var defaults = {
        numberOfParticles: 0,  // should be defined in config;
        header: undefined      // should be defined in config
      };
      
      $scope.config = angular.extend(defaults, config);
      
      $scope.init = function() {
        console.log($scope.config.header);
        for(var i = 0; i < $scope.config.numberOfParticles; i++) {
          var p = new ParticleModel({
            id: i,
            boxSize: {
              width: $scope.config.header[0].offsetWidth,
              height: $scope.config.header[0].offsetHeight
            },
            header: $scope.config.header,
            controller: $scope
          }).init();
          
          $scope.numParticles++;
          $scope.config.header.append(p.config.domElement);
        }
      };
      
      return $scope;
    }

    var pc = new ParticleController({
      numberOfParticles: 20,
      header: angular.element(document.querySelector('.header'))
    }).init();
              
            
!
999px

Console