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

              
                <div class="container">
    <div class="content">
        <h3>CSS Only Material Design Button Ripple Effect</h3>
        <p>I was looking at the Google Material Design stuff and wanted to see if I could approximate the click ripple effect using CSS only.<br />The requirements I had:</p>
        <ul>
          <li>CSS only</li>
          <li>No extra HTML elements</li>
          <li>No extra Javascript</li>
        </ul>
        <p>The result:</p>
        <div>
          <button class="button-base ripple">Ripple Button</button>
          <button class="button-base ripple">Ripple Button</button>
          <button class="button-base ripple">Ripple Button</button>
        <div>
        <p>Problems:</p>
        <ul>
          <li>To size and position the ripple, I had to use absolute fixed sizes and positioning, <br />so the scale and timing would be off if the element is much larger than a button</li>
          <li>No Javascript, so can't position the ripple at the click origin</li>
          <li>Browser compatibility? ¯\_(ツ)_/¯</li>
          <li>The click uses :focus, so it's only going through once</li>
        </ul>
    </div>
</div>

              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto);

.ripple{
  position: relative;
  overflow: hidden; 
}

.ripple:before {
  border-radius: 50%;
  background-color: rgba(255,255,255,0.6);
  content:'';
  position: absolute;
  top: 50%; left: 50%;
  width:0; height:0;
}

.ripple:focus:before {
  transition: all 0.5s ease-out;
  opacity:0;
  width:160px;
  height:160px;
  margin-top:-80px;
  margin-left:-80px;
}

.button-base:hover{
  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.3);  
}

.button-base{
  font-family: 'Roboto', sans-serif;
  -webkit-appearance: none;
  border: none;
  text-transform: none;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  background: #4285f4;
  color: #fff;
  vertical-align: middle;
  border-radius: 3px;
  line-height: 36px;
  min-height: 36px;
  font-size: 14px;
  text-align: center;
  text-decoration:none;
  text-transform: uppercase;
  min-width: 5.14em;
  padding:0 1em;
  margin: 0 0.25em;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.37);
}

.button-base:focus{
  outline:0;
}

html, body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: table;
}
.container {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}
.content {
    display: inline-block;
    text-align: left;
}
              
            
!

JS

              
                
              
            
!
999px

Console