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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <pre class="language-javascript">
function logStuff() {
  var stuff = "I am logging this.";
  console.log(stuff);  
}
</pre>
            
          
!

CSS

            
              $radius: 5px
$background: #272822

body
  max-width: 500px
  margin: 0 auto
  padding: 100px 0
  
pre[class*="language-"]
  position: relative
  overflow: visible
  border-radius: $radius
  .copy
    content: "copy"
    padding: 2px 10px 0
    position: absolute
    top: 0
    right: 0
    transform: translate(-10px, -90%)
    border-top-left-radius: $radius
    border-top-right-radius: $radius
    color: white
    background: $background
    cursor: pointer
    transition: all 200ms ease
  &:hover .copy
    transform: translate(-10px, -100%)
    &:hover
      color: gray
  
code
  overflow: scroll
            
          
!

JS

            
              //
// al pre tags on the page
const pres = document.getElementsByTagName("pre")

//
// reformat html of pre tags
if (pres !== null ) {
  for (let i = 0; i < pres.length; i++) {
    // check if its a pre tag with a prism class
    if (isPrismClass(pres[i])) {
      // insert code and copy element
      pres[i].innerHTML = `<div class="copy">copy</div><code class="${pres[i].className}">${pres[i].innerHTML}</code>`      
    }
  }
}

//
// create clipboard for every copy element
const clipboard = new Clipboard('.copy', {
  target: (trigger) => {
    return trigger.nextElementSibling;
  }
});

//
// do stuff when copy is clicked
clipboard.on('success', (event) => {
  event.trigger.textContent = 'copied!';
  setTimeout(() => {
    event.clearSelection();
    event.trigger.textContent = 'copy';
  }, 2000);
});

//
// helper function
function isPrismClass(preTag) { 
  return preTag.className.substring(0, 8) === 'language'
}
            
          
!
999px

Console