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="wrapper" id="grained">
  <h1>Static</h1>
  <div class="sub-title">Pressure</div>
</div>
              
            
!

CSS

              
                * {box-sizing: border-box;}

body {
  margin: 0; 
  font-family: 'Space Grotesk', sans-serif; 
  color: hsl(20, 10%, 90%); 
  background: hsl(0, 0%, 10%);
}

.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 2;
}

#grained {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
}

h1 {
  font-size: 5rem;
  line-height: 1;
  margin: 0;
}

.sub-title {
  letter-spacing: 16px;
  text-transform: uppercase;
  margin-right: -16px;
  margin-top: 12px
}

@-ms-keyframes grained {
  0% {
    -ms-transform: translate(-10%, 10%);
  }
  10% {
    -ms-transform: translate(-25%, 0%);
  }
  20% {
    -ms-transform: translate(-30%, 10%);
  }
  30% {
    -ms-transform: translate(-30%, 30%);
  }
  40% {
    -ms-transform: translate();
  }
  50% {
    -ms-transform: translate(-15%, 10%);
  }
  60% {
    -ms-transform: translate(-20%, 20%);
  }
  70% {
    -ms-transform: translate(-5%, 20%);
  }
  80% {
    -ms-transform: translate(-25%, 5%);
  }
  90% {
    -ms-transform: translate(-30%, 25%);
  }
  100% {
    -ms-transform: translate(-10%, 10%);
  }
}
@-webkit-keyframes grained {
  0% {
    -webkit-transform: translate(-10%, 10%);
  }
  10% {
    -webkit-transform: translate(-25%, 0%);
  }
  20% {
    -webkit-transform: translate(-30%, 10%);
  }
  30% {
    -webkit-transform: translate(-30%, 30%);
  }
  40% {
    -webkit-transform: translate();
  }
  50% {
    -webkit-transform: translate(-15%, 10%);
  }
  60% {
    -webkit-transform: translate(-20%, 20%);
  }
  70% {
    -webkit-transform: translate(-5%, 20%);
  }
  80% {
    -webkit-transform: translate(-25%, 5%);
  }
  90% {
    -webkit-transform: translate(-30%, 25%);
  }
  100% {
    -webkit-transform: translate(-10%, 10%);
  }
}
@-o-animation-keyframes grained {
  0% {
    -o-animation-transform: translate(-10%, 10%);
  }
  10% {
    -o-animation-transform: translate(-25%, 0%);
  }
  20% {
    -o-animation-transform: translate(-30%, 10%);
  }
  30% {
    -o-animation-transform: translate(-30%, 30%);
  }
  40% {
    -o-animation-transform: translate();
  }
  50% {
    -o-animation-transform: translate(-15%, 10%);
  }
  60% {
    -o-animation-transform: translate(-20%, 20%);
  }
  70% {
    -o-animation-transform: translate(-5%, 20%);
  }
  80% {
    -o-animation-transform: translate(-25%, 5%);
  }
  90% {
    -o-animation-transform: translate(-30%, 25%);
  }
  100% {
    -o-animation-transform: translate(-10%, 10%);
  }
}
@-moz-keyframes grained {
  0% {
    -moz-transform: translate(-10%, 10%);
  }
  10% {
    -moz-transform: translate(-25%, 0%);
  }
  20% {
    -moz-transform: translate(-30%, 10%);
  }
  30% {
    -moz-transform: translate(-30%, 30%);
  }
  40% {
    -moz-transform: translate();
  }
  50% {
    -moz-transform: translate(-15%, 10%);
  }
  60% {
    -moz-transform: translate(-20%, 20%);
  }
  70% {
    -moz-transform: translate(-5%, 20%);
  }
  80% {
    -moz-transform: translate(-25%, 5%);
  }
  90% {
    -moz-transform: translate(-30%, 25%);
  }
  100% {
    -moz-transform: translate(-10%, 10%);
  }
}
@keyframes grained {
  0% {
    transform: translate(-10%, 10%);
  }
  10% {
    transform: translate(-25%, 0%);
  }
  20% {
    transform: translate(-30%, 10%);
  }
  30% {
    transform: translate(-30%, 30%);
  }
  40% {
    transform: translate();
  }
  50% {
    transform: translate(-15%, 10%);
  }
  60% {
    transform: translate(-20%, 20%);
  }
  70% {
    transform: translate(-5%, 20%);
  }
  80% {
    transform: translate(-25%, 5%);
  }
  90% {
    transform: translate(-30%, 25%);
  }
  100% {
    transform: translate(-10%, 10%);
  }
}
              
            
!

JS

              
                /*! Grained.js
* Author : Sarath Saleem  - https://github.com/sarathsaleem
* MIT license: http://opensource.org/licenses/MIT
* GitHub : https://github.com/sarathsaleem/grained
* v0.0.1
*/
(function (window, doc) {

  "use strict";

  function grained(ele, opt) {

    var element = null,
        elementId = null,
        selectorElement = null;

    if (typeof ele === 'string') {
      element = doc.getElementById(ele.split('#')[1]);
    }

    if (!element) {
      console.error('Grained: cannot find the element with id ' + ele);
      return;
    } else {
      elementId = element.id;
    }

    //set style for parent
    if (element.style.position !== 'absolute') {
      element.style.position = 'relative';
    }
    element.style.overflow = 'hidden';

    var prefixes = ["", "-moz-", "-o-animation-", "-webkit-", "-ms-"];

    //default option values
    var options = {
      animate: true,
      patternWidth: 100,
      patternHeight: 100,
      grainOpacity: 0.1,
      grainDensity: 1,
      grainWidth: 1,
      grainHeight: 1,
      grainChaos: 0.5,
      grainSpeed: 20

    };

    Object.keys(opt).forEach(function (key) {
      options[key] = opt[key];
    });


    var generateNoise = function () {
      var canvas = doc.createElement('canvas');
      var ctx = canvas.getContext('2d');
      canvas.width = options.patternWidth;
      canvas.height = options.patternHeight;
      for (var w = 0; w < options.patternWidth; w += options.grainDensity) {
        for (var h = 0; h < options.patternHeight; h += options.grainDensity) {
          var rgb = Math.random() * 256 | 0;
          ctx.fillStyle = 'rgba(' + [rgb, rgb, rgb, options.grainOpacity].join() + ')';
          ctx.fillRect(w, h, options.grainWidth, options.grainHeight);
        }
      }
      return canvas.toDataURL('image/png');
    };

    function addCSSRule(sheet, selector, rules, index) {
      var ins = '';
      if (selector.length) {
        ins = selector + "{" + rules + "}";
      } else {
        ins = rules;
      }

      if ("insertRule" in sheet) {
        sheet.insertRule(ins, index);
      } else if ("addRule" in sheet) {
        sheet.addRule(selector, rules, index);
      }
    }


    var noise = generateNoise();

    var animation = '',
        keyFrames = ['0%:-10%,10%', '10%:-25%,0%', '20%:-30%,10%', '30%:-30%,30%', '40%::-20%,20%', '50%:-15%,10%', '60%:-20%,20%', '70%:-5%,20%', '80%:-25%,5%', '90%:-30%,25%', '100%:-10%,10%'];

    var pre = prefixes.length;
    while (pre--) {
      animation += '@' + prefixes[pre] + 'keyframes grained{';
      for (var key = 0; key < keyFrames.length; key++) {
        var keyVal = keyFrames[key].split(':');
        animation += keyVal[0] + '{';
        animation += prefixes[pre] + 'transform:translate(' + keyVal[1] + ');';
        animation += '}';
      }
      animation += '}';
    }

    //add animation keyframe
    var animationAdded = doc.getElementById('grained-animation');
    if (animationAdded) {
      animationAdded.parentElement.removeChild(animationAdded);
    }
    var style = doc.createElement("style");
    style.type = "text/css";
    style.id = 'grained-animation';
    style.innerHTML = animation;
    doc.body.appendChild(style);

    //add custimozed style
    var styleAdded = doc.getElementById('grained-animation-' + elementId);
    if (styleAdded) {
      styleAdded.parentElement.removeChild(styleAdded);
    }

    style = doc.createElement("style");
    style.type = "text/css";
    style.id = 'grained-animation-' + elementId;
    doc.body.appendChild(style);

    var rule = 'background-image: url(' + noise + ');';
    rule += 'position: absolute;content: "";height: 300%;width: 300%;left: -100%;top: -100%;';
    pre = prefixes.length;
    if (options.animate) {
      while (pre--) {
        rule += prefixes[pre] + 'animation-name:grained;';
        rule += prefixes[pre] + 'animation-iteration-count: infinite;';
        rule += prefixes[pre] + 'animation-duration: ' + options.grainChaos + 's;';
        rule += prefixes[pre] + 'animation-timing-function: steps(' +options.grainSpeed + ', end);';
      }
    }

    //selecter element to add grains
    selectorElement = '#' + elementId + '::before';


    addCSSRule(style.sheet, selectorElement, rule);


  }

  window.grained = grained;
  //END
})(window, document);



var options = {
  animate: true,
  patternWidth: 500,
  patternHeight: 500,
  grainOpacity: 0.11,
  grainDensity: 1.3,
  grainWidth: 1,
  grainHeight: 1
};

grained('#grained',options);

              
            
!
999px

Console