cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <a href="#" class='btn open-modal' data-modal="#modal1">Open Modal</a>

<div class='modal' id='modal1'>
	<div class='content'>
		<h1 class='title'>This is a modal</h1>
		<p>
				Here is some text and stuff. cool cool	
		</p>
		<a class='btn close-modal' data-modal="#modal1" href="#">K Bye</a>
	</div>	
</div>	
            
          
!
            
              $red: #EF233C
$blue: #2B2D42
$orange: #FF9F1C

*
	box-sizing: border-box

body
	font-family: 'Nunito', sans-serif
	min-height: 100vh
	display: flex
	justify-content: center
	align-items: center

.btn
	padding: 20px 50px
	display: inline-block
	background: $red
	color: white
	text-decoration: none
	transition: 0.35s ease-in-out
	font-weight: 700
	&:hover
		background: darken($red, 7.5%)

.overlay
	width: 100%
	min-height: 100vh
	display: flex
	justify-content: center
	align-items: center
	flex-direction: column
	padding: 40px
	position: fixed
	top: 0
	left: 0
	background: rgba(black, 0.75)
	opacity: 0
	pointer-events: none
	transition: 0.35s ease-in-out
	max-height: 100vh
	overflow-y: auto
	&.open
		opacity: 1
		pointer-events: inherit
	.modal
		background: white
		text-align: center
		padding: 40px 80px
		box-shadow: 0px 1px 10px rgba(white, 0.35)
		opacity: 0
		pointer-events: none
		transition: 0.35s ease-in-out
		max-height: 100vh
		overflow-y: auto
		&.open
			opacity: 1
			pointer-events: inherit
			.content
				transform: translate(0, -0px)
				opacity: 1
		.content
			transform: translate(0, -10px)
			opacity: 0
			transition: .35s ease-in-out
		.title
			margin-top: 0


            
          
!
            
              $(".modal").each( function(){
	$(this).wrap('<div class="overlay"></div>')
});

$(".open-modal").on('click', function(e){
	e.preventDefault();
	e.stopImmediatePropagation;
	
	var $this = $(this),
			modal = $($this).data("modal");
	
	$(modal).parents(".overlay").addClass("open");
	setTimeout( function(){
		$(modal).addClass("open");
	}, 350);
	
	$(document).on('click', function(e){
		var target = $(e.target);
		
		if ($(target).hasClass("overlay")){
			$(target).find(".modal").each( function(){
				$(this).removeClass("open");
			});
			setTimeout( function(){
				$(target).removeClass("open");
			}, 350);
		}
		
	});
	
});

$(".close-modal").on('click', function(e){
	e.preventDefault();
	e.stopImmediatePropagation;
	
	var $this = $(this),
			modal = $($this).data("modal");
	
	$(modal).removeClass("open");
	setTimeout( function(){	
		$(modal).parents(".overlay").removeClass("open");
	}, 350);
	
});	
            
          
!
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.
Loading ..................

Console