Pen Settings



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


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


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.


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.


                <p id="p1">
  This demo shows how to add live mini-previews to links on hover. Check out these links to <a href="">Codrops</a> and <a href="">A List Apart</a>. Hover over them to see a small preview of what they point to.
<p class="break">&bull; &bull; &bull;</p>
<p id="p2">
  Those previews were fetched as soon as this page loaded. This is great for having the previews ready ahead of time, but can eat up extra bandwidth. As an alternative, check out these links to <a href="">WebAIM</a> and <a href="">CSS-Tricks</a>. These previews aren't fetched until you hover over this paragraph.
<p class="break">&bull; &bull; &bull;</p>
<p id="p3">
  Finally, check out these links to <a href="">Daniel's blog</a>, <a href="">Joni's blog</a>, and <a href="">my blog</a>. These previews are only fetched when needed. This saves the most bandwidth, but there will be a delay before the previews can be shown.


                @import url(;

body {
  height: 100%;
  margin: 0;
  padding: 0 10% 40px;
  font-size: 2rem;
  line-height: 1.5;
  font-family: 'Roboto Slab', sans-serif;
  text-align: justify;
  color: #59513f;
  background-color: #f5ead4;

a {
  display: inline-block;
  position: relative;
  white-space: nowrap;
  color: #537f7c;

.break {
  text-align: center;

.mini-preview-wrapper {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  position: absolute;
  overflow: hidden;
  z-index: -1;
  opacity: 0;
  margin-top: -4px;
  border: solid 1px #000;
  box-shadow: 4px 4px 6px rgba(0, 0, 0, .3);
  transition: z-index steps(1) .3s, opacity .3s, margin-top .3s;

a:hover .mini-preview-wrapper {
  z-index: 2;
  opacity: 1;
  margin-top: 6px;
  transition: opacity .3s, margin-top .3s;

.mini-preview-loading, .mini-preview-cover {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;  

.mini-preview-loading {
  display: table;
  height: 100%;
  width: 100%;
  font-size: 1.25rem;
  text-align: center;
  color: #f5ead4;
  background-color: #59513f;

.mini-preview-loading::before {
  content: 'Loading...';
  display: table-cell;
  text-align: center;
  vertical-align: middle;

.mini-preview-cover {
  background-color: rgba(0, 0, 0, 0); /* IE fix */

.mini-preview-frame {
  border: none;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;


                $(function() {
  // attach mini-previews
  $('#p1 a').miniPreview({ prefetch: 'pageload' });
  $('#p2 a').miniPreview({ prefetch: 'parenthover' });
  $('#p3 a').miniPreview({ prefetch: 'none' });

(function($) {
  var PREFIX = 'mini-preview';
  // implemented as a jQuery plugin
  $.fn.miniPreview = function(options) {
    return this.each(function() {
      var $this = $(this);
      var miniPreview = $;
      if (miniPreview) {

      miniPreview = new MiniPreview($this, options);
      $, miniPreview);
  var MiniPreview = function($el, options) {
    this.$el = $el;
    this.options = $.extend({}, this.defaultOptions, options);
    this.counter = MiniPreview.prototype.sharedCounter++;
  MiniPreview.prototype = {
    sharedCounter: 0,
    defaultOptions: {
      width: 256,
      height: 144,
      scale: .25,
      prefetch: 'pageload'
    generate: function() {

    createElements: function() {
      var $wrapper = $('<div>', { class: PREFIX + '-wrapper' });
      var $loading = $('<div>', { class: PREFIX + '-loading' });
      var $frame = $('<iframe>', { class: PREFIX + '-frame' });
      var $cover = $('<div>', { class: PREFIX + '-cover' });
      $wrapper.appendTo(this.$el).append($loading, $frame, $cover);
      // sizing
        width: this.options.width + 'px',
        height: this.options.height + 'px'
      // scaling
      var inversePercent = 100 / this.options.scale;
        width: inversePercent + '%',
        height: inversePercent + '%',
        transform: 'scale(' + this.options.scale + ')'

      // positioning
      var fontSize = parseInt(this.$el.css('font-size').replace('px', ''), 10)
      var top = (this.$el.height() + fontSize) / 2;
      var left = (this.$el.width() - $wrapper.outerWidth()) / 2;
        top: top + 'px',
        left: left + 'px'
    setPrefetch: function() {
      switch (this.options.prefetch) {
        case 'pageload':
        case 'parenthover':
        case 'none':
          throw 'Prefetch setting not recognized: ' + this.options.prefetch;
    loadPreview: function() {
      this.$el.find('.' + PREFIX + '-frame')
        .attr('src', this.$el.attr('href'))
        .on('load', function() {
          // some sites don't set their background color
          $(this).css('background-color', '#fff');
    getNamespacedEvent: function(event) {
      return event + '.' + PREFIX + '_' + this.counter;

    destroy: function() {
      this.$el.find('.' + PREFIX + '-wrapper').remove();