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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

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.

            
              <section class="cd-section">
		<p>
			Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non ipsum repudiandae sequi ut optio reiciendis consectetur, cum, a provident, iusto quod esse, perferendis iure iste! Quidem itaque, exercitationem aliquam, mollitia recusandae repellat dolores quibusdam minima quae reprehenderit ut, reiciendis officia.
		</p>

		<div class="cd-modal-action">
			<a href="#0" class="btn" data-type="modal-trigger">Fire Modal Window</a>
			<span class="cd-modal-bg"></span>
		</div> <!-- cd-modal-action -->

		<div class="cd-modal">
			<div class="cd-modal-content">
				<p>
					Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad modi repellendus, optio eveniet eligendi molestiae? Fugiat, temporibus! A rerum pariatur neque laborum earum, illum voluptatibus eum voluptatem fugiat, porro animi tempora? Sit harum nulla, nesciunt molestias, iusto aliquam aperiam est qui possimus reprehenderit ipsam ea aut assumenda inventore iste! Animi quaerat facere repudiandae earum quisquam accusamus tempora, delectus nesciunt, provident quae aliquam, voluptatum beatae quis similique in maiores repellat eligendi voluptas veniam optio illum vero! Eius, dignissimos esse eligendi veniam.
				</p>

				<p>
					Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad modi repellendus, optio eveniet eligendi molestiae? Fugiat, temporibus! A rerum pariatur neque laborum earum, illum voluptatibus eum voluptatem fugiat, porro animi tempora? Sit harum nulla, nesciunt molestias, iusto aliquam aperiam est qui possimus reprehenderit ipsam ea aut assumenda inventore iste! Animi quaerat facere repudiandae earum quisquam accusamus tempora, delectus nesciunt, provident quae aliquam, voluptatum beatae quis similique in maiores repellat eligendi voluptas veniam optio illum vero! Eius, dignissimos esse eligendi veniam.
				</p>

				<p>
					Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad modi repellendus, optio eveniet eligendi molestiae? Fugiat, temporibus! A rerum pariatur neque laborum earum, illum voluptatibus eum voluptatem fugiat, porro animi tempora? Sit harum nulla, nesciunt molestias, iusto aliquam aperiam est qui possimus reprehenderit ipsam ea aut assumenda inventore iste! Animi quaerat facere repudiandae earum quisquam accusamus tempora, delectus nesciunt, provident quae aliquam, voluptatum beatae quis similique in maiores repellat eligendi voluptas veniam optio illum vero! Eius, dignissimos esse eligendi veniam.
				</p>
			</div> <!-- cd-modal-content -->
		</div> <!-- cd-modal -->

		<a href="#0" class="cd-modal-close">Close</a>
	</section> <!-- .cd-section -->
            
          
!
            
              @import "bourbon";

// breakpoints
   
$S:     480px;   
$M:     768px;     
$L:     1170px;     

// media queries

@mixin MQ($canvas) {
  @if $canvas == S {
   @media only screen and (min-width: $S) { @content; } 
  }
  @else if $canvas == M {
   @media only screen and (min-width: $M) { @content; } 
  }
  @else if $canvas == L {
   @media only screen and (min-width: $L) { @content; } 
  }
}

// antialiasing mode font rendering

@mixin font-smoothing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// colors

$color-1: #34383c; // Outer Space
$color-2: #03bb91; // Caribbean Green
$color-3: #ffffff; // White

// fonts 

$primary-font: 'Source Sans Pro', sans-serif;

/* -------------------------------- 

Primary style

-------------------------------- */

*, *::after, *::before {
	@include box-sizing(border-box);
}

html {
	font-size: 62.5%;
}

body {
	font: {
		size: 1.6rem;
		family: $primary-font;
	}
	color: $color-1;
	background-color: $color-3;

	&.overflow-hidden {
		/* used when modal is visible */
		overflow: hidden;
	}
}

a {
	color: $color-2;
	text-decoration: none;
}

/* -------------------------------- 

Main Components 

-------------------------------- */

.cd-section {
	padding: 2em 5%;
	text-align: center;
	background-color: $color-2;

	p {
		margin: 2em 0;
		line-height: 1.6;
		color: $color-3;
		@include font-smoothing;
	}

	@include MQ(M) {
		padding: 4em 10%;

		p {
			font-size: 1.8rem;
			line-height: 2;
		}
	}

	@include MQ(L) {
		padding: 4em 20%;
	}
}

.cd-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;

	visibility: hidden;
	opacity: 0;
	pointer-events: none;

	@include transition(visibility 0s .3s, opacity .3s 0s, z-index 0s .3s);

	&::after {
		/* gradient overlay at bottom of modal window */
		content: '';
		position: absolute;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 60px;
		pointer-events: none;
		background: transparent;
		@include background(linear-gradient(to top,rgba($color-1, 1), rgba($color-1, 0)));
	}

	.cd-modal-content {
		height: 100%;
		width: 100%;
		padding: 3em 5%;
		text-align: left;
		overflow-y: auto; 
		@include font-smoothing; 
	}

	p {
		color: $color-3;
		line-height: 1.6;
		margin: 2em 0;
	}

	.modal-is-visible & {
		z-index: 1;
		visibility: visible;
		opacity: 1;
		pointer-events: auto;
		
		@include transition(visibility 0s 0s, opacity .3s 0s, z-index 0s 0s);

		.cd-modal-content {
			-webkit-overflow-scrolling: touch;
		}
	}

	@include MQ(M) {

		.cd-modal-content { 
			padding: 4em 10%;
		}
	}

	@include MQ(L) {

		.cd-modal-content { 
			padding: 6em 20%;
		}

		p {
			font-size: 2rem;
			line-height: 2;
		}
	}
}

.cd-modal-action {
	position: relative;

	.btn, .cd-modal-bg {
		display: inline-block;
		height: 4em;
		background-color: $color-1;
	}
	
	.btn {
		width: 12.5em;
		border-radius: 5em;

		color: $color-3;
		line-height: 4em;
		white-space: nowrap;
		font-weight: 700;
		@include font-smoothing;
		
		@include transition(color .2s .3s, width .3s 0s);

		&.to-circle {
			width: 4em;
			color: transparent;
			@include transition(color .2s 0s, width .3s .2s);
		}
	}

	.cd-modal-bg {
		position: absolute;
		z-index: 1;
		left: 50%;
    	top: 0;
		width: 4em;
		border-radius: 50%;
		opacity: 0;
		visibility: hidden;
    	@include transform(translateZ(0));
    	@include transform(translateX(-2em));
		@include transition(visibility 0s .5s);

		&.is-visible {
			opacity: 1;
			visibility: visible;
		}
	}
}

.cd-modal-close {
	position: fixed;
	z-index: 1;
	top: 20px;
	right: 5%;

	height: 50px;
	width: 50px;
	border-radius: 50%;
	
	background: rgba(#000, .3) url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/cd-icon-close_copy.svg) no-repeat center center;
	
	/* image replacement */
	overflow: hidden;
	text-indent: 100%;
	white-space: nowrap;

	visibility: hidden;
	opacity: 0;
	@include transform(translateZ(0));
	@include transform(scale(0));
	@include transition(transform .3s 0s, visibility 0s .3s, opacity .3s 0s);

	.no-touch &:hover {
		background-color: rgba(#000, .5);
	}

	.modal-is-visible & {
		visibility: visible;
		opacity: 1;
		@include transition(transform .3s 0s, visibility 0s 0s, opacity .3s 0s);
		@include transform(scale(1));
	}

	@include MQ(M) {
		top: 70px;
	}
}
            
          
!
            
              jQuery(document).ready(function($){
	//trigger the animation - open modal window
	$('[data-type="modal-trigger"]').on('click', function(){
		var actionBtn = $(this),
			scaleValue = retrieveScale(actionBtn.next('.cd-modal-bg'));
		
		actionBtn.addClass('to-circle');
		actionBtn.next('.cd-modal-bg').addClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			animateLayer(actionBtn.next('.cd-modal-bg'), scaleValue, true);
		});

		//if browser doesn't support transitions...
		if(actionBtn.parents('.no-csstransitions').length > 0 ) animateLayer(actionBtn.next('.cd-modal-bg'), scaleValue, true);
	});

	//trigger the animation - close modal window
	$('.cd-section .cd-modal-close').on('click', function(){
		closeModal();
	});
	$(document).keyup(function(event){
		if(event.which=='27') closeModal();
	});

	$(window).on('resize', function(){
		//on window resize - update cover layer dimention and position
		if($('.cd-section.modal-is-visible').length > 0) window.requestAnimationFrame(updateLayer);
	});

	function retrieveScale(btn) {
		var btnRadius = btn.width()/2,
			left = btn.offset().left + btnRadius,
			top = btn.offset().top + btnRadius - $(window).scrollTop(),
			scale = scaleValue(top, left, btnRadius, $(window).height(), $(window).width());

		btn.css('position', 'fixed').velocity({
			top: top - btnRadius,
			left: left - btnRadius,
			translateX: 0,
		}, 0);

		return scale;
	}

	function scaleValue( topValue, leftValue, radiusValue, windowW, windowH) {
		var maxDistHor = ( leftValue > windowW/2) ? leftValue : (windowW - leftValue),
			maxDistVert = ( topValue > windowH/2) ? topValue : (windowH - topValue);
		return Math.ceil(Math.sqrt( Math.pow(maxDistHor, 2) + Math.pow(maxDistVert, 2) )/radiusValue);
	}

	function animateLayer(layer, scaleVal, bool) {
		layer.velocity({ scale: scaleVal }, 400, function(){
			$('body').toggleClass('overflow-hidden', bool);
			(bool) 
				? layer.parents('.cd-section').addClass('modal-is-visible').end().off('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend')
				: layer.removeClass('is-visible').removeAttr( 'style' ).siblings('[data-type="modal-trigger"]').removeClass('to-circle');
		});
	}

	function updateLayer() {
		var layer = $('.cd-section.modal-is-visible').find('.cd-modal-bg'),
			layerRadius = layer.width()/2,
			layerTop = layer.siblings('.btn').offset().top + layerRadius - $(window).scrollTop(),
			layerLeft = layer.siblings('.btn').offset().left + layerRadius,
			scale = scaleValue(layerTop, layerLeft, layerRadius, $(window).height(), $(window).width());
		
		layer.velocity({
			top: layerTop - layerRadius,
			left: layerLeft - layerRadius,
			scale: scale,
		}, 0);
	}

	function closeModal() {
		var section = $('.cd-section.modal-is-visible');
		section.removeClass('modal-is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
			animateLayer(section.find('.cd-modal-bg'), 1, false);
		});
		//if browser doesn't support transitions...
		if(section.parents('.no-csstransitions').length > 0 ) animateLayer(section.find('.cd-modal-bg'), 1, false);
	}
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console