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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="display">
  <h2>Sweet whale sounds, bro.</h2>
  <div class="play-button" onClick="togglePlay()">
    <i class="fa fa-play"></i>
    <i class="fa fa-pause"></i>
  </div>
</div>
              
            
!

CSS

              
                body
  height: 100vh
  width: 100vw
  margin: 0
  box-sizing: border-box
  background: rgb(195,115,238)
  background: linear-gradient(45deg, rgba(195,115,238,1) 0%, rgba(43,65,207,1) 100%)
  font-family: 'helvetica', 'arial', open-sans
  *
    box-sizing: border-box
  
h2 
  color: #FFF
  
/* Just to center everything
.display
  position: absolute
  top: 50%
  left: 50%
  transform: translate(-50%,-50%)

/* Play Button 
.play-button
  height: 100px
  width: 100px
  border-radius: 50px
  background: rgb(254,118,51)
  background: linear-gradient(0deg, rgba(254,118,51,1) 0%, rgba(253,197,65,1) 100%)
  text-align: center
  box-shadow: 0 0 5px rgba(0,0,0,.3)
  cursor: pointer
  margin: 0 auto
  &.pause
    .fa-pause
      display: block
    .fa-play
      display: none
  .fa-pause
    position: relative
    display: none
    left: 0
  .fa-play
    position: relative
    left: 4px
  i
    text-align: center
    font-size: 60px
    line-height: 100px
    color: #FFF
    opacity: .8
    text-shadow: 0 0 8px rgba(0,0,0,.4)
              
            
!

JS

              
                // Get Audio Track
var myAudio = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/77682/whales-short.mp3');
  
// Init isPlaying Variable
var isPlaying = false;

// Pause or Play Audio
function togglePlay() {
  if (isPlaying) {
    jQuery(".play-button").removeClass("pause");
    myAudio.pause()
  } else {
    jQuery(".play-button").addClass("pause");
    myAudio.play();
  }
};

myAudio.onplaying = function() {
  isPlaying = true;
};
  
myAudio.onpause = function() {
  isPlaying = false;
};
              
            
!
999px

Console