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.

Quick-add: + add another resource

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.

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 id="img"></div>
<!--
Glitches by itself && on mouseover
!-->
            
          
!
            
              html,
body {
  height: 100%
}

body {
  background: hsla(260, 95%, 45%, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-image: linear-gradient(to right top, hsla(0, 5%, 5%, 0.5), hsla(260, 95%, 45%, 1));
}

div#img {
  height: 400px;
  width: 300px;
  cursor: pointer;
}
            
          
!
            
              (function() {
  
var set = function(x, opts) {
    var _pt = [{
      x: 0,
      y: 0
    }, {
      x: 0,
      y: 0
    }, {
      x: 0,
      y: 0
    }];
    var rnd1 = [Math.random() + 1, Math.random() + 1, Math.random() + 1];
    var rnd2 = [0, 0, 0];
    var cnt = 0;
    var arr = [];
    var loop = null;
    var t = null;
    var _h = opts._h;
    var _w = opts._w;
    var img = opts.img;
    var mshov = false;

    x.css({
      position: "relative"
    });

    for (var i = 0; i < _h; i++) {
      var pos = -i + "px";
      x.append("<div></div>");
      x.find("div").eq(i).css({
        backgroundImage: "url(" + img + ")",
        backgroundPosition: "0px " + pos,
        height: "1px",
        width: _w + "px",
        position: "absolute",
        top: i + "px"
      });
      arr.push(x.find("div").eq(i));
    }

    if (opts.auto) {
      t = setInterval(function() {
        if (mshov) return;
        go();

        setTimeout(pause, opts.delay / 2 * Math.random());
      }, opts.delay);
    }

    x.mouseover(go);
    x.mouseout(pause);

    function go() {
      mshov = true;
      clearInterval(loop);
      loop = setInterval(run, 30);
    }

    function pause() {
      mshov = false;
      clearInterval(loop);
      loop = null;

      for (var i = 0; i < _h; i++) {
        arr[i].css({
          left: 0
        });
      }
    }

    function run() {
      var i;
      for (i = 0; i < 3; i++) {
        if (rnd1[i] >= 1) {
          --rnd1[i];
          rnd2[i] = Math.random() / 4 + 0.03;
        }
        rnd1[i] += rnd2[i];
        cnt += (38 - cnt) * 0.25;
        _pt[i].x = Math.ceil(Math.sin(rnd1[i] * Math.PI * 2) * rnd2[i] * cnt * 2);
        _pt[i].y = 0;
      }
      var num = (Math.abs(_pt[0].x) + Math.abs(_pt[1].x) + Math.abs(_pt[2].x) + 8) / 4;

      i = _h;
      while (i -= 1) {
        var _off = Math.sin(i / _h * Math.PI * (Math.random() / 8 + 1)) * 0.8 * num * num;
        arr[i].css({
          left: _off + "px "
        });
      }
    }
  };

  jQuery.fn.noisy = function(opts) {
    this.each(function() {
      opts = jQuery.extend({}, jQuery.fn.noisy.defs, opts);
      set(jQuery(this), opts);
    });
  };

  jQuery.fn.noisy.defs = {
    _h: 0,
    _w: 0,
    img: "",
    auto: true,
    delay: 4000
  };

})();

/*to see this same image but with its full background use 
https://s3-us-west-2.amazonaws.com/s.cdpn.io/131045/noise.jpe | I removed the black image bordering.
Or add any other image of your choice - just be sure to edit the width/height params below. It *should* work with any image.
*/
$(function() {
  $("#img").noisy({
    _w: 360,
    _h: 350,
    img: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/131045/ns2.png"
  });
});
            
          
!
999px
Loading ..................

Console