Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <html>
	<head>
		<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,700,500' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css" />
	</head>
  <body>
    <h1>Android L ripple effect <br /><span class="secondary-text">( without Polymer and jQuery )</span></h1>
    <p>Just add 'material' attribute to any DOM element. <br />
      Supports both mouse and touch events. See more at <a href="http://coderorder.com" target="_blank">http://coderorder.com</a>
    
    </p>
		
    <h2>Flat buttons</h2>
    <div class="buttons-wrapper">
    	<button material>Button</button>
    	<button material class="colored-btn">Colored</button>
       <button material disabled>Test</button>
    </div>
    
    <h2>Raised buttons</h2>
    <div class="buttons-wrapper">
    	<button material raised>Button</button>
    	<button material raised colored class="colored-btn">Colored</button>
       <button material raised disabled>Test</button>
    </div>
    
    <h2>Floated buttons</h2>
    <div class="buttons-wrapper">
    	<button material primary class="floated">
    		<i class="fa fa-lock"></i>
    	</button>
      <button material secondary class="floated">
    		<i class="fa fa-lock"></i>
    	</button>
    </div>
 
    
  </body>
</html>


              
            
!

CSS

              
                /**
* Demo settings
*/
body { margin: 0; background: #fff; font-family: 'Roboto'; font-weight: 300; }
h1 { font-weight: 300; text-align: center; }
h2 { font-size: 1.16em; text-align: center; font-family: 'Roboto' font-weight: 500; margin-top: 25px; margin-bottom: 5px; }
h1 .secondary-text { font-size: .6em; }
p { text-align: center; }
button { display: block; padding: 8px 6px; margin: 1em; width: 10em; font-size: 1em; text-transform: uppercase; }
.buttons-wrapper { display: flex; justify-content: center; }
.colored-btn { color: rgb(66, 133, 244); }
button.floated {  }

/* End demo */



[material] { position: relative; overflow: hidden;  text-align: center; border: none; background: none; }
[material][disabled] { background: rgb(234, 234, 234); }
 
[material][primary] { background: #cecece; width: 56px; height: 56px; -webkit-clip-path: circle(32px at 32px 32px); clip-path: circle(32px at 32px 32px); line-height: 32px; border-radius: 50%; font-size: 24px; }
[material][raised] { border-radius: 3px; }
[material][raised]:not([disabled]) { box-shadow: 0 3px 3px rgba(0, 0, 0, 0.16), 0 3px 3px rgba(0, 0, 0, 0.23); 
transition: .3s all ease-in-out; background: #dfdfdf;
}
[material][raised]:not([disabled]):hover,
[material][raised]:not([disabled]):active
{ box-shadow: 0 14px 14px rgba(0, 0, 0, 0.25), 0 10px 5px rgba(0, 0, 0, 0.22); }

[material][raised][colored] { color: #fff; background: #4285f4; }

[material][secondary] { background: #cecece; width: 40px; height: 40px; -webkit-clip-path: circle(40px at 20px 20px); clip-path: circle(40px at 20px 20px); line-height: 16px; border-radius: 50%; font-size: 18px; }
[material]:focus { outline: none; }

.ripple { display: block; position: absolute; background: rgba(0,0,0,.1); border-radius: 100%; -webkit-transform: scale(0); transform: scale(0); }
/*animation effect*/
.ripple.animate { -webkit-animation: ripple 0.65s linear; animation: ripple 0.65s linear; }

@-webkit-keyframes ripple {
	100% {opacity: 0; -webkit-transform: scale(2.5); transform: scale(2.5);}
}
@keyframes ripple { 100% {opacity: 0; -webkit-transform: scale(2.5); transform: scale(2.5);}
}

              
            
!

JS

              
                /**
 * Helper function, that allows to attach multiple events to selected objects
 * @param {[object]}   el       [selected element or elements]
 * @param {[type]}   events   [DOM object events like click or touch]
 * @param {Function} callback [Callback method]
 */
var addMulitListener = function(el, events, callback) {
  // Split all events to array
  var e = events.split(' ');
  
    // Loop trough all elements
    Array.prototype.forEach.call(el, function(element, i) {
      // Loop trought all events and add event listeners to each
      Array.prototype.forEach.call(e, function(event, i) {
        element.addEventListener(event, callback, false);
      });  
    });
}  ;

/**
 * This function is adding ripple effect to elements
 * @param  {[object]} e [DOM objects, that should apply ripple effect]
 * @return {[null]}   [description]
 */
addMulitListener(document.querySelectorAll('[material]'), 'click touchstart', function(e) { 
    var ripple = this.querySelector('.ripple');
    var eventType = e.type;
    /**
     * Ripple
     */
    if(ripple == null) {
      // Create ripple
      ripple = document.createElement('span'); 
      ripple.classList.add('ripple');
      
      // Prepend ripple to element
      this.insertBefore(ripple, this.firstChild);

      // Set ripple size
      if(!ripple.offsetHeight && !ripple.offsetWidth) {
        var size = Math.max(e.target.offsetWidth, e.target.offsetHeight);
        ripple.style.width = size + 'px';
        ripple.style.height = size + 'px';
      }

    }

    // Remove animation effect
    ripple.classList.remove('animate');

    // get click coordinates by event type
    if(eventType == 'click') {
      var x = e.pageX;
      var y = e.pageY;
    } else if(eventType == 'touchstart') {
      var x = e.changedTouches[0].pageX;
      var y = e.changedTouches[0].pageY;
    }
    x = x - this.offsetLeft - ripple.offsetWidth / 2;
    y = y - this.offsetTop - ripple.offsetHeight / 2;

    // set new ripple position by click or touch position
    ripple.style.top = y + 'px';
    ripple.style.left = x + 'px';
    ripple.classList.add('animate');
});   

              
            
!
999px

Console