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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <section>
  <textarea id="editor"></textarea>
  <iframe id="preview"></iframe>
</section>
<header>
  <span id="brand"><strong>Tinkerpad</strong> <span id="filename"></span></span>
  <nav>
    <button id="zen" onclick="swingPane('editor','preview')">zen</button>
    <button id="view" onclick="swingPane('preview','editor')">view</button>
    <button id="save" onclick="exportNote()">save</button>
    <button id="switch" onclick="switchNote()">switch</button>
  </nav>
</header>
<footer><a id="download" download="export.html"></a></footer>
            
          
!
            
              * {
  box-sizing: border-box;
}
::selection {
  background-color: #002b36;
}
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-weight: 300;
  font-family: 'Source Sans Pro', 'Open Sans', Roboto, 'Helvetica Neue', 'Segoe UI', 'Myriad Pro', Helvetica, Myriad, Arial, sans-serif;
}
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  color: #839496;
  background: #002b36;
  position: relative;
}
header {
  width: 100%;
  height: 50px;
  position: fixed;
  top: 0;
  left: 0;
  background: #073642;
  padding: 0 15px;
  box-shadow: rgba(0,0,0,.1) 0 1px 2px;
  z-index: 250;
  user-select: none;
}
header #brand {
  position: absolute;
  top: 50%;
  margin-top: -7pt;
}
header #brand strong {
  font-weight: 500;
}
header nav {
  float: right;
  background: #073642;
  position: relative;
}
header nav:before {
  content: '';
  display: block;
  width: 30px;
  height: 50px;
  position: absolute;
  top: 0;
  left: -30px;
  background: linear-gradient( to right, rgba(7,54,66,0) 0%, rgba(7,54,66,1) 100%);
}
header button {
  outline: none;
  width: 40px;
  height: 40px;
  border-radius: 40px;
  margin: 5px 0;
  padding: 0;
  line-height: 30px;
  border: 1px solid #586e75;
  color: #586e75;
  cursor: pointer;
  background: transparent;
  transition: all .1s ease-in-out;
  text-shadow: #002b36 0 2px 2px;
  box-shadow: #002b36 0 1px 2px;
}
header button:focus,
header button:hover {
  border-color: #839496;
  color: #839496;
}
header button:active {
  border-color: #93a1a1;
  color: #93a1a1;
}
header button + button {
  margin-left: 10px;
}
section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 50px 15px 30px 15px;
  z-index: 100;
}
#editor,
#preview {
  width: 49.25%;
  float: left;
  margin: 15px .75% 0 .75%;
  border-radius: 2px;
  transition: all .2s ease-in-out;
  -webkit-appearance: none;
  z-index: 500;
}
#editor {
  outline: none;
  transition: background-color .1s ease-in-out;
  font-family: 'Source Code Pro', Menlo, Consolas, monospace;
  color: #839496;
  background: #073642;
  outline: none;
  border: none;
  padding: 15px;
  font-size: 12pt;
  line-height: 1.2;
  font-weight: 300;
  height: auto;
  box-shadow: rgba(0,0,0,.1) 0 1px 2px;
  margin-left: 0;
}
#preview {
  background: #fff;
  opacity: 0.3;
  transition: opacity .1s ease-in-out;
  outline: none;
  appearance: none;
  border: none;
  box-shadow: rgba(0,0,0,.1) 0 1px 2px;
  margin-right: 0;
}
#preview:hover,
#preview:focus {
  opacity: 1;
  cursor: default;
}
footer {
  background: #073642;
  width: 100%;
  height: 30px;
  line-height: 30px;
  padding: 0 5px;
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 250;
  box-shadow: rgba(0,0,0,.1) 0 -1px 2px;
}
footer .download {
  position: absolute;
  top: 50px;
  left: 50px;
}
@media (max-width: 481px) {
  header #brand {
    font-size: 10pt;
  }
  header #brand strong {
    display: none;
  }
}
            
          
!
            
              var editorPane = document.getElementById('editor'),
    previewPane = document.getElementById('preview'),
    downloadLink = document.getElementById('download'),
        fileName = '';
// Editor Interactions
onload = editorPane.onkeyup = function() {
  refreshView();
  if(fileName == ''){ fileName = scratchpad /*switchNote()*/ };
  localStorage[fileName] = editorPane.value;
};
editorPane.onfocus= function() {
  this.style.webkitTransform = 'translate3D(0px, -10000px,0)';
  webkitRequestAnimationFrame(function() {
    this.style.webkitTransform = '';
  }.bind(this));
};
editorPane.onkeydown = function(event) {
  if(event.keyCode === 9) {
    softTab('  '); // tabs set at 2 spaces
    event.preventDefault();
  }
}
// Editor Functions
function refreshView() {
  editorPane.style.height = (window.innerHeight - 110) + 'px';
  previewPane.style.height = (window.innerHeight - 110) + 'px';
  (previewPane.contentWindow.document).write(editorPane.value);
  (previewPane.contentWindow.document).close();
  editorPane.focus();
}
function softTab(spaces) {
  if(document.selection) {
    editorPane.focus();
    var tab = document.selection.createRange();
    tab.text = spaces;
    return;
  }
  else if(editorPane.selectionStart || editorPage.selectionStart == '0') {
    var startPos = editorPane.selectionStart,
        endPos = editorPane.selectionEnd,
        scrollTop = editorPane.scrollTop;
        editorPane.value = editorPane.value.substring(0, startPos) + spaces + editorPane.value.substring(endPos, editorPane.value.length);
        editorPane.focus();
        editorPane.selectionStart = startPos + spaces.length;
        editorPane.selectionEnd = startPos + spaces.length;
  } else {
    editorPane.value += textArea.value;
    editorPane.focus();
  }
};
function switchNote() {
  fileName = prompt('Welcome to Tinkerpad\n\nThinkerpad is a mobile-friendly scratchpad for tinkering around with HTML, CSS, and JS in the browser. It can also be bookmarked for offline use.\n\nTo Use the Default Scratchpad:\nPress \'Enter\' or select \'Cancel\' to load the default scratchpad\n\nTo Create a New Scratchpad:\nEnter the name of the new scratchpad you wish to create and select \'OK\'\n\nTo Open a Saved Scratchpad:\nEnter the name of the saved scratchpad below to wish to continue editing and select \'OK\'\n\nSaved Scratchpads in This Browser:\n' + Object.keys(localStorage).join(", "), '');
  if(fileName == null || fileName == '') { fileName = 'scratchpad'; editorPane.value = localStorage[fileName] }
  if(localStorage[fileName] != ''){ editorPane.value = localStorage[fileName] }
  if(editorPane.value == 'undefined'){ editorPane.value = ''; }
  downloadLink.setAttribute('download', fileName + '.html');
  document.getElementById('filename').innerHTML = ': ' + fileName;
  document.title = 'Tinkerpad:' + fileName;
  refreshView();
};
function swingPane(reveal, conceal) {
  var revealPane = document.getElementById(reveal),
      concealPane = document.getElementById(conceal);
  if(revealPane.style.width != '100%') {
    concealPane.setAttribute('style', 'width: 0; margin: 0; padding: 0;');
    revealPane.setAttribute('style', 'width: 100%; margin-left: 0; opacity: 1;');
  } else {
    concealPane.setAttribute('style', 'width: 49.25%;');
    revealPane.setAttribute('style', 'width: 49.25%;');
  }
  refreshView();
};
function exportNote() {
  downloadLink.href = 'data:text/html;charset=utf-8,' + encodeURIComponent(editorPane.value);
  downloadLink.click();
};

            
          
!
999px
Loading ..................

Console