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 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

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='contentButton'>
  <button id="triggerPen" class="trigger-button" type="button"> Insertar PEN</button>
<button id="triggerCode" class="trigger-button" type="button">Convertir CÓDIGO</button>
</div>
  <div id="contentPen">
    <p data-height="365" data-theme-id="299" data-slug-hash="MKdZwK" data-default-tab="result" data-user="Kseso" class='codepen'>See the Pen <a href='https://codepen.io/Kseso/pen/MKdZwK/'>MKdZwK</a> by Kseso (<a href='https://codepen.io/Kseso'>@Kseso</a>) on <a href='https://codepen.io'>CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
  </div>
  <div id="contentCode">
    <p data-height="365" data-theme-id="299" data-slug-hash="vLwvrb" data-default-tab="result" data-user="Kseso" class='codepen'>See the Pen <a href='https://codepen.io/Kseso/pen/vLwvrb/'>Convertir HTML</a> by Kseso (<a href='https://codepen.io/Kseso'>@Kseso</a>) on <a href='https://codepen.io'>CodePen</a>.</p>
  </div>
              
            
!

CSS

              
                /* Modal Base CSS */
* {margin: 0;padding: 0; box-sizing: inherit;}
html {
  background: #F28DBE;
    font-family: Helvetica,Arial,san-serif;
    font-size: 1rem;
  box-sizing: border-box;
}
.scotch-overlay {
    position: fixed;
    z-index: 9998;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    transition: 1ms opacity ease;
    background: rgba(0,0,0,.6);
}
.scotch-modal {
    position: absolute;
    z-index: 9999;
    top: 50%;
    left: 50%;
    opacity: 0;
    width: 94%;
    border: 1px solid #fff;
    border-width: 24px;
    overflow: hidden;
    transition: 1ms opacity ease;
    transform: translate(-50%, -50%);
    border-radius: 3px;
    background: #fff;
}
.scotch-content {
  margin-top: -2.2rem;
}
.scotch-modal.scotch-open.scotch-anchored {
    top: 20px;
    transform: translate(-50%, 0);
}
.scotch-modal.scotch-open {
    opacity: 1;
}
.scotch-overlay.scotch-open {
    opacity: 1;
}
/* Close Button */
.scotch-close {
    font-family: Helvetica,Arial,sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    position: absolute;
    top: 5px;
    left: 5px;
    padding: 0 .5rem;
    cursor: pointer;
    color: #fff;
    outline: none;
    background: #6D78F8;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0, 0.3);
  transition: .4s;
}
.scotch-close:hover {
    background:  #A2C2F6;
}
/* Default Animation */
.scotch-overlay.fade-and-drop {
    display: block;
    opacity: 0;
}
.scotch-modal.fade-and-drop {
    top: -300%;
    opacity: 1;
    display: block;
}
.scotch-modal.fade-and-drop.scotch-open {
    top: 50%;
    transition: 500ms top 500ms ease;
}
.scotch-modal.fade-and-drop.scotch-open.scotch-anchored {
    transition: 500ms top 500ms ease;
}
.scotch-overlay.fade-and-drop.scotch-open {
    top: 0;
    transition: 500ms opacity ease;
    opacity: 1;
}
.scotch-modal.fade-and-drop {
  transition: 500ms top ease;
}
.scotch-overlay.fade-and-drop {
   transition: 500ms opacity 500ms ease;
}
.contentButton {
  display: flex;
  height: 100vh;  
}
#contentPen, #contentCode {
    display: none;
}
.trigger-button {
  background: #A2F29C;
  color: #444;
  font-size: 1.2rem;
  line-height: 5;
  font-variant: small-caps;
  letter-spacing: 2px;
  min-width: 40vw;
  max-height: 25vh;
  margin: auto;
  padding: 0 1.5rem;
  border: 0 none;
  cursor: pointer;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0, 0.3);
  transition: .4s;
}
.trigger-button:nth-child(2) {background: #F1EF7E;}
.trigger-button:hover {
  box-shadow: inset 0 0 0 3rem  rgba(0,0,0, 0.35);
}
              
            
!

JS

              
                // Derivada de https://scotch.io/tutorials/building-your-own-javascript-modal-plugin
// Create an immediately invoked functional expression to wrap our code
(function() {

  // Define our constructor 
  this.Modal = function() {

    // Create global element references
    this.closeButton = null;
    this.modal = null;
    this.overlay = null;

    // Determine proper prefix
    this.transitionEnd = transitionSelect();

    // Define option defaults 
    var defaults = {
      autoOpen: false,
      className: 'fade-and-drop',
      closeButton: true,
      content: "",
      maxWidth: 600,
      minWidth: 280,
      overlay: true
    }

    // Create options by extending defaults with the passed in arugments
    if (arguments[0] && typeof arguments[0] === "object") {
      this.options = extendDefaults(defaults, arguments[0]);
    }

    if(this.options.autoOpen === true) this.open();

  }

  // Public Methods

  Modal.prototype.close = function() {
    var _ = this;
    this.modal.className = this.modal.className.replace(" scotch-open", "");
    this.overlay.className = this.overlay.className.replace(" scotch-open",
      "");
    this.modal.addEventListener(this.transitionEnd, function() {
      _.modal.parentNode.removeChild(_.modal);
    });
    this.overlay.addEventListener(this.transitionEnd, function() {
      if(_.overlay.parentNode) _.overlay.parentNode.removeChild(_.overlay);
    });
  }

  Modal.prototype.open = function() {
    buildOut.call(this);
    initializeEvents.call(this);
    window.getComputedStyle(this.modal).height;
    this.modal.className = this.modal.className +
      (this.modal.offsetHeight > window.innerHeight ?
        " scotch-open scotch-anchored" : " scotch-open");
    this.overlay.className = this.overlay.className + " scotch-open";
  }

  // Private Methods

  function buildOut() {

    var content, contentHolder, docFrag;

    /*
     * If content is an HTML string, append the HTML string.
     * If content is a domNode, append its content.
     */

    if (typeof this.options.content === "string") {
      content = this.options.content;
    } else {
      content = this.options.content.innerHTML;
    }

    // Create a DocumentFragment to build with
    docFrag = document.createDocumentFragment();

    // Create modal element
    this.modal = document.createElement("div");
    this.modal.className = "scotch-modal " + this.options.className;
    this.modal.style.minWidth = this.options.minWidth + "px";
    this.modal.style.maxWidth = this.options.maxWidth + "px";

    // If closeButton option is true, add a close button
    if (this.options.closeButton === true) {
      this.closeButton = document.createElement("button");
      this.closeButton.className = "scotch-close close-button";
      this.closeButton.innerHTML = "&times;";
      this.modal.appendChild(this.closeButton);
    }

    // If overlay is true, add one
    if (this.options.overlay === true) {
      this.overlay = document.createElement("div");
      this.overlay.className = "scotch-overlay " + this.options.className;
      docFrag.appendChild(this.overlay);
    }

    // Create content area and append to modal
    contentHolder = document.createElement("div");
    contentHolder.className = "scotch-content";
    contentHolder.innerHTML = content;
    this.modal.appendChild(contentHolder);

    // Append modal to DocumentFragment
    docFrag.appendChild(this.modal);

    // Append DocumentFragment to body
    document.body.appendChild(docFrag);

  }

  function extendDefaults(source, properties) {
    var property;
    for (property in properties) {
      if (properties.hasOwnProperty(property)) {
        source[property] = properties[property];
      }
    }
    return source;
  }

  function initializeEvents() {

    if (this.closeButton) {
      this.closeButton.addEventListener('click', this.close.bind(this));
    }

    if (this.overlay) {
      this.overlay.addEventListener('click', this.close.bind(this));
    }

  }

  function transitionSelect() {
    var el = document.createElement("div");
    if (el.style.WebkitTransition) return "webkitTransitionEnd";
    if (el.style.OTransition) return "oTransitionEnd";
    return 'transitionend';
  }

}());

var myContentPen = document.getElementById('contentPen');

var myModalPen = new Modal({
  content: myContentPen
});

var triggerButton = document.getElementById('triggerPen');

triggerButton.addEventListener('click', function() {
  myModalPen.open();
});

var myContentCode = document.getElementById('contentCode');

var myModalCode = new Modal({
  content: myContentCode
});

var triggerButton = document.getElementById('triggerCode');

triggerButton.addEventListener('click', function() {
  myModalCode.open();
});

              
            
!
999px

Console