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

              
                .container
	h1 Send a postcard
	.info *
		.more-info
			.image
				img(src="https://assets.codepen.io/567707/palette-reputation.png" alt="Taylor Swift album")
			p Part of the 
				a(href="https://codepen.io/collection/XPxJmz") UI Designs inspired by Taylor Swift Album Covers
				|  collection. This is 
				em reputation (2017)
				|.
	
	.inner
		.postcard
			<svg class="close-this" xmlns="http://www.w3.org/2000/svg" id="Capa_1" enable-background="new 0 0 413.348 413.348" height="512" viewBox="0 0 413.348 413.348" width="512"><path d="m413.348 24.354-24.354-24.354-182.32 182.32-182.32-182.32-24.354 24.354 182.32 182.32-182.32 182.32 24.354 24.354 182.32-182.32 182.32 182.32 24.354-24.354-182.32-182.32z"/></svg>
			.postcard__chosen
				img.chosen-card(src="https://assets.codepen.io/567707/cat-molly.png")
				.name Molly
			.postcard__back
				textarea Write your message here... &#13;&#10; &#13;&#10; &#13;&#10;&#13;&#10;p/s this doesn't actually send anything :(
				.address
					input(type="text" placeholder="Receiver's name")
					input(type="email" placeholder="Receiver's email")
					button Send
					
					
					img.stamp(src="https://assets.codepen.io/567707/icon-stamp.svg" alt="paw stamp")
					
		.cover.cover__cat
			a(data-type="cat").js-cat.circle Cat
			img(src="https://assets.codepen.io/567707/pattern-cat.jpg" alt="Cat Pattern")
			.options.cat-options
				.options__item(data-name="Molly")
					img(src="https://assets.codepen.io/567707/cat-molly.png" alt="Cat")
				.options__item(data-name="Kato")
					img(src="https://assets.codepen.io/567707/cat-kato.jpg" alt="Cat")
				.options__item(data-name="Haru")
					img(src="https://assets.codepen.io/567707/cat-underscore.png" alt="Cat")
				.options__item(data-name="Whiskey")
					img(src="https://assets.codepen.io/567707/cat-whiskey.jpg" alt="Cat")
		.cover.cover__dog
			a(data-type="dog").js-dog.circle Dog
			img(src="https://assets.codepen.io/567707/pattern-dog.jpg" alt="Dog Pattern")
			.options.dog-options
				.options__item(data-name="Joey")
					img(src="https://assets.codepen.io/567707/dog-joey.png" alt="Dog")
				.options__item(data-name="Fred")
					img(src="https://assets.codepen.io/567707/dog-pom-2.png" alt="Dog")
				.options__item(data-name="Creamy")
					img(src="https://assets.codepen.io/567707/dog-creamy.jpg" alt="Dog")
				.options__item(data-name="Pepper")
					img(src="https://assets.codepen.io/567707/dog-pepper.jpg" alt="Dog")
	
              
            
!

CSS

              
                :root {
	--white: #ffffff;
	--black-5: #f5f5f5;
	--black-10: #e4e4e4;
	--black-20: #c9c9c9;
	--black-30: #aeaeae;
	--black-50: #939393;
	--black-60: #787878;
	--black-70: #5d5d5d;
	--black-80: #424242;
	--black-90: #272727;
	--black: #0c0c0c;
}
body {
	background: #fff;
	font-family: Berkshire Swash, cursive;
}
* {
	box-sizing: border-box;
}

img {
	filter: grayscale(100%);
}

em {
	font-style: italic;
}

h1 {
	font-family: ZCOOL XiaoWei, serif;
	text-transform: uppercase;
	text-align: center;
	font-size: clamp(2.4rem, 3vw, 4rem);
	letter-spacing: 0.3rem;
	padding: 0.5rem 0.5rem 1.2rem;
}

.container {
	background: var(--black);
	padding: .5rem;
	height: 100vh;
	width: 100%;
	min-width: 550px;
	background: var(--white);
	border: 0.2rem solid var(--black);
	display: flex;
	flex-direction: column;
	@media(max-width: 550px) {
			overflow: auto;
		height: 150vh;
		}
	.inner {
		border: 0.2rem solid var(--black);
		flex: 1;
		display: flex;
		position: relative;
		overflow: hidden;
		
	}
}

.cover {
	flex: 1;
	position: relative;
	user-select: none;
	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		pointer-events: none;
	}
	&__cat {
		border-right: 2px solid var(-black);
	}
	&__dog {
		border-left: 2px solid var(--black);
	}
}

a.circle {
	font-family: Berkshire Swash, cursive;
	position: absolute;
	width: 9rem;
	height: 9rem;
	top: 50%;
	left: 50%;
	z-index: 4;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--black);
	font-size: 3rem;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--white);
	cursor: pointer;
	&:hover {
		background: var(--black-80);
	}
	&:focus,
	&:active {
		background: var(--black-60);
	}
}

.options {
	width: 100%;
	position: absolute;
	top: -100%;
	
	left: 0;
	height: 100%;
	background: #fff;
	z-index: 8;
	display: grid;
	grid: repeat(2, 50%) / repeat(2, 1fr);
	transition: .4s ease-in-out;
	&.active {
		top: 0;
	}
	@media (max-width: 700px) {
		grid: repeat(4, 25%) / 100%;
	}
	&__item {
		padding: 0.4rem;
		line-height: 0;
		margin: 1rem auto;
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
		@media (max-width: 700px) {
			margin: 0;
		}
		img {
			width: 75%;
			height: 100%;
			object-fit: cover;
			border: 6px solid var(--white);
			outline: 2px solid var(--black);
			transform: .4s ease;
			&:hover {
				border-color: var(--white);
			}
			@media (max-width: 700px) {
				width: 100%;
				height: 100%;
			}
		}
		@media (min-width: 700px) {
			&:nth-child(1) {
				transform: rotate(5deg) translate(0.8rem, 0.5rem);
			}
			&:nth-child(2) {
				transform: rotate(-2deg) translate(-0.8rem, 0.6rem);
			}
			&:nth-child(3) {
				transform: translate(0.8rem, -0.6rem);
			}
			&:nth-child(4) {
				transform: rotate(-6deg) translate(-0.8rem, -0.6rem);
			}
		}
	}
}

.postcard {
	width: 100%;
	height: 100%;
	background-image: url("https://assets.codepen.io/567707/paper_fibers.png");
	position: absolute;
	z-index: 100;
	left: -100%;
	transition: .5s ease-in-out;
	opacity: 0;
	&.active {
		left: 0;
		opacity: 1;
	}
	.chosen-card {
		border: 1px solid var(--black);
		width: 100%;
		
	}
	
	.name {
		font-family: ZCOOL XiaoWei, serif;
		text-transform: uppercase;
		text-align: center;
		font-size: clamp(1.8rem, 2.5vw, 3rem);
		letter-spacing: 0.3rem;
		padding: 0.8rem 0.8rem 1rem;
		background: var(--white);
		position: absolute;
		bottom: 0;
		width: 100%;
		text-align: center;
		left: 0;
	}
	&__chosen {
		border: 2px solid var(--black);
		padding: .8rem;
		display: inline-block;
		background: var(--white);
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-130%, -50%) rotate(-5deg);
		width: 40%;
		max-width: 19rem;
		min-width: 17rem;
		transition: .3s ease;
		@media(max-width: 800px) {
			transform: translate(-100%, -50%) rotate(-5deg)
		}
		@media(max-width: 550px) {
			transform: translate(-100%, -100%) rotate(-5deg)
		}
		
	}
	&__back {
		border: 2px solid var(--black);
		padding: 2rem;
		position: absolute;
		background: var(--white);
		left: 40%;
		top: 40%;
		transform: translate(-10%, -40%) rotate(2deg);
		display: flex;
		transition: .3s ease;
		@media(max-width: 800px) {
			transform: translate(-30%, -50%) rotate(2deg);
		}
		> * {
			flex: 1;
		}
		textarea {
			resize: none;
			margin-right: 2rem;
			border: none;
			font-size: 120%;
			&:focus {
				outline: none;
				background: var(--black-5);
			}
		}
	}
	.stamp {
		position: absolute;
		width: 15%;
		max-width: 5rem;
		right: 1rem;
		top: 1rem;
	}
	.address {
		border-left: 1px solid var(--black);
		padding: 4.5rem 0 0 2rem;
		
	}
	.close-this {
		position: absolute;
		right: 1rem;
		top: 1rem;
		width: 2rem;
		height: 2rem;
		cursor: pointer;
	}
}

input {
	width: 100%;
	font-family: Berkshire Swash, cursive;
	margin: .5rem 0;
	border: 1px solid;
	border-width: 0 0 1px;
	font-size: 1.2rem;
	padding: .5rem .8rem;
	@media(max-width: 800px) {
		padding: .3rem .5rem;
		font-size: 1rem;
	}
	&:focus {
		outline: none;
		background: var(--black-5);
		
	}
}

button {
	width: 100%;
	background: var(--black-90);
	cursor: pointer;
	font-family: ZCOOL XiaoWei, serif;
	text-transform: uppercase;
	text-align: center;
	font-size: 1.4rem;
	padding: .8rem;
	margin-top: 1rem;
	border: none;
	color: var(--white);
	@media(max-width: 800px) {
		font-size: 1rem;
		padding: .5rem;
		margin-top: .4rem;
	}
	&:hover {
		background: var(--black-90);
	}
	&:focus, &:active {
		background: var(--black-80);
		outline: none;
	}
}


.info {
	position: absolute;
	font-size: 3rem;
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	right: .8rem;
	top: .8rem;
	padding: .2rem;
	text-align: center;
	background: var(--black);
	color: white;
	cursor: pointer;
	&:hover {
		background: var(--black-90);
		.more-info {
			display: flex;
		}
	}
	.more-info {
		display: none;
		align-items: center;
		background: var(--black-60);
		color: var(--red);
		position: absolute;
		right: 0;
		width: 30rem;
		z-index: 100;
		font-size: 1rem;
		text-align: left;
		top: 105%;
		line-height: 1.3;
		a {
			color: var(--red-dark);
		}
		.image {
			flex: 0 0 30%;
			max-width: 10rem;
			line-height: 0;
			img {
				width: 100%;
			}
		}
		p {
			flex: 1;
			padding: 0 1.5rem;
		}
	}
}
              
            
!

JS

              
                $('a.circle').on('click', function(){
	var animal = $(this).data('type');
	if (animal == 'cat') {
		$('.cat-options').addClass('active');
		$('.dog-options').removeClass('active');
	} else if (animal == 'dog') {
		$('.dog-options').addClass('active');
		$('.cat-options').removeClass('active');
	}
});

$('.options__item').on('click', function(){
	var photo = $(this).find('img').attr('src');
	$('.chosen-card').attr('src',photo);
	$('.postcard').addClass('active');
	$('.name').text($(this).data('name'));
});

$(window).on("load resize",function(e){
  var width =  $('.postcard__chosen').outerHeight();
	var height = $('.postcard__chosen').outerWidth();
	$('.postcard__back').outerHeight(height*1.1);
	$('.postcard__back').outerWidth(width*1.1);
});

$('.close-this').on('click', function(){
	$('.postcard').removeClass('active');
});
              
            
!
999px

Console