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.

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.

HTML

              
                <div id="wrapper" class="wrapper card">
	
	<div class="thumbnail">
		
	</div>
	
	<div class="content">
			
		<h1 class="title">A Thing</h1>

		<h3 class="price">$15.00</h3>

		<p class="description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc et orci at odio luctus laoreet eget ac ante.</p>
	
		<button id="AddToCart" class="AddToCart card">

			<span>Add To Cart</span>

		</button>
		
	</div>
	
</div>
              
            
!

CSS

              
                body {
	background: #f4f5f7;
	font-family: helvetica, arial
}

	body * {
		transition: all .3s ease-in-out;
	}

	.wrapper {
		min-width: 300px;
		max-width: 600px;
		width: 60%;
		background: #17cae6;
		margin: auto;
		margin-top: 50px;
	}

		.thumbnail {
			width: 100%;
			height: 200px;
			background: rgba(0, 0, 0, .2);
		}

		.content {
			padding: 20px;
		}

			.content .title {
				margin: 0px;
				color: rgba(244, 245, 247, 1);
			}

			.content .price {
				margin: 0px;
				color: rgba(244, 245, 247, .8);
			}

			.content .description {
				color: rgba(43, 50, 51, .9);
			}

		button {
			background: #f4f5f7;
			border: none;
			color: rgba(43, 50, 51, .9);
			font-size: 1.5em;
			outline: none;
			position: relative;
			overflow: hidden;
			max-width: 200px;
			max-height: 100px;
			cursor: pointer;
		}

			button:not(.Loading):hover {
				box-shadow: 0px 5px 7px rgba(0, 0, 0, .2), 0px 9px 11px rgba(0, 0, 0, .15);
			}

		.AddToCart {
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 50px auto 0px auto;
		}

			.AddToCart span {
				display: inline-block;
				min-width: 150px;
				padding: 10px 20px;
				z-index: 2;
			}

			.AddToCart.Loading {
				border-radius: 25px;
				max-width: 50px;
				max-height: 50px;
				cursor: default;
			}

				.AddToCart.Loading span {
					opacity: 0;
				}

			.AddToCart::after {
				content: " ";
				border-top: solid 4px #17cae6;
				border-right: solid 4px #17cae6;
				border-bottom: solid 4px #17cae6;
				border-left: solid 4px transparent;
				border-radius: 50px;
				position: absolute;
				top: 7px;
				right: 7px;
				bottom: 7px;
				left: 7px;
				margin: auto;
				max-width: 30px;
				max-height: 30px;
				opacity: 0;
				z-index: 1;
			}

				.AddToCart.Loading::after {
					animation: fadeIn .3s ease-in, spin 1.3s infinite ease-in-out;
					animation-fill-mode: forwards;
				}

.Notify {
	position: fixed;
	bottom: 25px;
	left: 0px;
	right: 0px;
	text-align: center;
}

	.Notify p {
		padding: 10px;
		background: #2b3233;
		border-radius: 3px;
		color: #f4f5f7;
		display: inline;
		box-shadow: 0px 3px 5px rgba(0, 0, 0, .2), 0px 5px 7px rgba(0, 0, 0, .15);
		animation: fadeIn .3s ease-in;
		font-weight: 100;
	}

.card {
	border-radius: 3px;
	box-shadow: 0px 3px 5px rgba(0, 0, 0, .2), 0px 5px 7px rgba(0, 0, 0, .15);
}

.hide {
	opacity: 0;
}

@keyframes spin {
	0%, 5% {
		transform: rotate(0deg);
	}
	95%, 100% {
		transform: rotate(360deg);
	}
}

@keyframes fadeIn {
	0% {
		opacity: 0;
	}
	100% {
		opacity: 1;
	}
}
              
            
!

JS

              
                var AddToCart = document.getElementById('AddToCart');

var addItem = function() {
	
	AddToCart.classList.add('Loading')
	
	window.setTimeout(function() {
		
		AddToCart.classList.remove('Loading')
		
		Notify.Add('Item added to cart.')
		
	}, 3000)
	
}

var Notify = {
	
	Remove: function() {
		
		var Notification = document.querySelector('.Notify')
		
		Notification.classList.add('hide')
		
		setTimeout(function() {
			
			Notification.parentNode.removeChild(Notification)
			
		}, 2000)
		
	},
	
	Add: function(msg) {
		
		var check = document.querySelector('.Notify')
		var notification = this.Create(msg)
		var wrapper = document.getElementById('wrapper')
		
		if (check) {
			
			this.Remove()
			
		}
		
		document.body.insertBefore(notification, wrapper.nextSibling)
		
		setTimeout(this.Remove, 3000)
		
	},
	
	Create: function(msg) {
		
		var wrapper = document.createElement('div')
		var content = document.createElement('p')
		var text = document.createTextNode(msg)
		
  	content.appendChild(text)
  	wrapper.appendChild(content)
		
		wrapper.classList.add('Notify')
		
		return wrapper
		
	}
	
}

AddToCart.addEventListener('click', addItem)
              
            
!
999px

Console