Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

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

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

Auto Save

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <a href="#add-to-basket" class="fancybox small">Click to launch</a>
<a href="#also-add-to-basket" class="fancybox">Click to launch</a>

<!-- [Fancybox] ADD TO BASKET -->
<div class="overlay" id="add-to-basket">
  <h3 class="overlay__title">Add Product to Basket</h3>
  <form class="form-hr">
    <div class="boxout">
      <div class="form-hr__group">
        <label class="form-hr__label label">Name of Track by A. Composer</label>
        <div class="form-hr__controls form-controls">
          <label class="radiobtn"><input type="radio" name="radio" checked="checked" /> Full Pack <span class="lighten">(inc. all versions and loops)</span></label>
          <label class="radiobtn"><input type="radio" name="radio" /> Loops Only</label>
        </div>
      </div>
      <div class="form-hr__group">
        <label class="form-hr__label label">Name of Track by A. Composer</label>
        <div class="form-hr__controls form-controls">
          <label class="radiobtn"><input type="radio" name="radio" checked="checked" /> Full Pack <span class="lighten">(inc. all versions and loops)</span></label>
          <label class="radiobtn"><input type="radio" name="radio" /> Loops Only</label>
        </div>
      </div>
      <div class="form-hr__group form-hr__group--footer">
        <p><strong>Price</strong> <span class="lighten">(standard licence)</span> <strong class="align-r">$69.99</strong></p>
      </div>
    </div>
    <div class="form-group btn-group">
      <button href="#product-added" class="btn btn--lrg btn-group__btn fancybox">Add to Basket</button>
    </div>
  </form>
</div>

<div class="overlay" id="also-add-to-basket">
  <h3 class="overlay__title">Add Product to Basket</h3>
  <form class="form-hr">
    <div class="boxout">
      <div class="form-hr__group">
        <label class="form-hr__label label">Name of Track by A. Composer</label>
        <div class="form-hr__controls form-controls">
          <label class="radiobtn"><input type="radio" name="radio" checked="checked" /> Full Pack <span class="lighten">(inc. all versions and loops)</span></label>
          <label class="radiobtn"><input type="radio" name="radio" /> Loops Only</label>
        </div>
      </div>
      <div class="form-hr__group">
        <label class="form-hr__label label">Name of Track by A. Composer</label>
        <div class="form-hr__controls form-controls">
          <label class="radiobtn"><input type="radio" name="radio" checked="checked" /> Full Pack <span class="lighten">(inc. all versions and loops)</span></label>
          <label class="radiobtn"><input type="radio" name="radio" /> Loops Only</label>
        </div>
      </div>
      <div class="form-hr__group form-hr__group--footer">
        <p><strong>Price</strong> <span class="lighten">(standard licence)</span> <strong class="align-r">$69.99</strong></p>
      </div>
    </div>
    <div class="form-group btn-group">
      <button href="#product-added" class="btn btn--lrg btn-group__btn fancybox">Add to Basket</button>
    </div>
  </form>
</div>
              
            
!

CSS

              
                // Hide overlays

body {
  background: #eee;
  margin: 0 auto;
  padding: 50px 0 0;
  width: 100%;
  max-width: 1000px;
}

// Hide overlays

.overlay {
  display: none;
}




// FANCYBOX v2.1.5

// FANCYBOX v2.1.5

.fancybox-wrap,
.fancybox-skin,
.fancybox-outer,
.fancybox-inner,
.fancybox-image,
.fancybox-wrap iframe,
.fancybox-wrap object,
.fancybox-nav,
.fancybox-nav span,
.fancybox-tmp {
	border: 0;
	margin: 0;
	outline: none;
	padding: 0;
	vertical-align: top;
}

.fancybox-wrap {
	background: #fff;
	box-shadow: 0 0 50px 10px rgba(0,0,0,.50);
	margin-bottom: 20px;
	left: 0;
	position: absolute;
	top: 0;
	z-index: 8020;
}

.fancybox-skin {
	//background: #fff;
	position: relative;
	text-shadow: none;
}

.fancybox-opened {
	z-index: 8030;
}

.fancybox-opened .fancybox-skin {}

.fancybox-outer, 
.fancybox-inner {
	position: relative;
}

.fancybox-inner {
	overflow: hidden;
}

.fancybox-type-iframe .fancybox-inner {
	-webkit-overflow-scrolling: touch;
}

.fancybox-error {
	color: #444;
	font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
	margin: 0;
	padding: 15px;
	white-space: nowrap;
}

.fancybox-image, 
.fancybox-iframe {
	display: block;
	height: 100%;
	width: 100%;
}

.fancybox-image {
	max-height: 100%;
	max-width: 100%;
}

#fancybox-loading {
	cursor: pointer;
	left: 50%;
	margin-left: -20px;
	margin-top: -20px;
	opacity: 0.80;
	position: fixed;
	top: 50%;
	z-index: 8060;
	
	div {
		background: #000 url('../img/interface/ajax-loader-on-black.gif') center center no-repeat;
		height: 40px;
		width: 40px;
	}
}

.fancybox-prev span,
.fancybox-next span {
	background-image: url('../img/sprite/interface.png');
}

.fancybox-close {
	color: rgb(216,225,229);
	cursor: pointer;
	padding: 0;
	position: absolute;
	right: 20px;
	top: 20px;
	z-index: 8040;
	
	&:before {
		margin: 0;
	}
	
	span {
		display: none;
	}
	
	&:active {
		top: 21px;
	}
}

.fancybox-nav {
	background: transparent url('../img/interface/blank.gif'); /* helps IE */
	cursor: pointer;
	height: 100%;
	position: absolute;
	-webkit-tap-highlight-color: rgba(0,0,0,0);
	text-decoration: none;
	top: 0;
	width: 40%;
	z-index: 8040;
}

.fancybox-prev,
.fancybox-next {
	
	&:focus {
		outline: 0;
	}
	
	.btn {
		cursor: pointer;
		height: 30px;
		left: 0;
		margin-top: -15px;
		padding: 0;
		position: absolute;
		top: 50%;
		visibility: hidden;
		width: 30px;
		z-index: 8040;
	}
	
	.btn {
		left: 10px;
	}
	
	span {
		display: block;
		height: 100%;
		width: 100%;
	}
}

.fancybox-next {
	right: 0;
	
	.btn {
		left: auto;
		right: 10px;
	}
}

.fancybox-prev span {background-position: 2px -298px;}
.fancybox-next span {background-position: -48px -298px;}

.fancybox-nav:hover .btn {
	visibility: visible;
}

.fancybox-tmp {
	max-height: 99999px;
	left: -99999px;
	overflow: visible !important;
	position: absolute;
	top: -99999px;
	visibility: hidden;
	max-width: 99999px;
}

/* Overlay helper */

.fancybox-lock {
    overflow: hidden !important;
    width: auto;
}

.fancybox-lock body {
    overflow: hidden !important;
}

.fancybox-lock-test {
    overflow-y: hidden !important;
}

.fancybox-overlay {
	background: rgba(0,0,0,.50);
	display: none;
	left: 0;
	overflow: hidden;
	position: absolute;
	top: 0;
	z-index: 8010;
}

.fancybox-overlay-fixed {
	bottom: 0;
	position: fixed;
	right: 0;
}

.fancybox-lock .fancybox-overlay {
	overflow: auto;
	overflow-y: scroll;
}

/* Title helper */

.fancybox-opened .fancybox-title {
	visibility: visible;
}

.fancybox-title {
	padding: 10px 0 0;
	visibility: hidden;
	width: 100%;
}

.lt-ie9 .fancybox-title {
	width: 100% !important;
}
              
            
!

JS

              
                $(document).ready(function() {
  $(".fancybox").fancybox({
    margin: [20, 20, 20, 20],
    padding: [20, 20, 0, 20],
    openEffect: 'fade',
    openEasing: 'easeInQuad',
    openSpeed: 400,
    title: false,
    //closeBtn: false,
    //autoCenter: false,
    scrolling: 'no', // turns off scrolling in box.
    fitToView: false, // allows box to overflow out of viewport.
    autoSize: false, // needs to be turned off for width/maxWidth to work.
    height: 'auto', // if autoSize is set to 'false', this needs to be 'auto' so height matches content.
    width: '100%',
    maxWidth: 960,
    helpers: {
      overlay: {
        // locked: false, // Prevents jump to top of window when opening a fancybox.
        showEarly: false
      }
    },
    tpl: {
      closeBtn: '<a title="Close" class="fancybox-item fancybox-close icon-circle-cross" href="javascript:;"><span>Close</span></a>'
    },
    beforeLoad: function() {
      if ($(this.element).hasClass('small')) this.width = '40%';
    }
  });
});
              
            
!
999px
If a groundhog inspects their Web Component, do they see their Shadow DOM?

Console