Pen Settings

HTML

CSS

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

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

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.

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

              
                
<ul id="nav">
	<li class="lowercase"><label for="put-cards-down">(Put cards down)</label></li>
	<li><label for="toggle-card-1">First card</label></li>
	<li><label for="toggle-card-2">Second card</label></li>
	<li><label for="toggle-card-3">Third card</label></li>
	<li><label for="toggle-card-4">Fourth card</label></li>
</ul>


<h1 id="pen-title">Pure CSS Card Deck</h1>
<div id="pen-description">(Requires enough window height)</div>


<input type="radio" name="cards" class="card-checkbox" id="toggle-card-1">

<div class="card">
	<h2>First card</h2>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates nihil dolore, cumque molestiae doloribus necessitatibus! Nisi perferendis ipsam, harum itaque.</p>
</div>


<input type="radio" name="cards" class="card-checkbox" id="toggle-card-2">

<div class="card">
	<h2>Second card</h2>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates nihil dolore, cumque molestiae doloribus necessitatibus! Nisi perferendis ipsam, harum itaque.</p>
</div>


<input type="radio" name="cards" class="card-checkbox" id="toggle-card-3">

<div class="card">
	<h2>Third card</h2>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates nihil dolore, cumque molestiae doloribus necessitatibus! Nisi perferendis ipsam, harum itaque.</p>
</div>


<input type="radio" name="cards" class="card-checkbox" id="toggle-card-4">

<div class="card">
	<h2>Fourth card</h2>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates nihil dolore, cumque molestiae doloribus necessitatibus! Nisi perferendis ipsam, harum itaque.</p>
</div>


<input type="radio" name="cards" class="card-checkbox" id="put-cards-down">

              
            
!

CSS

              
                
html { font-size: 16px; }

body { background-color: #181818; }


#pen-title,
#pen-description {
	position: fixed;
	top: 40%;
	left: 50%;
	z-index: 0;
	color: #484848;
}

#pen-title {
	transform: translate(-50%, -125%);
	font-size: 2rem;
	text-transform: uppercase;
}

#pen-description {
	transform: translate(-50%, 125%);
	font-size: 1.125rem;
}


// Hide cards' checkboxes

.card-checkbox { display: none; }


// Cards

.card {
	$width: 640px;
	$height: $width * 0.67;
	
	box-sizing: border-box;
	position: fixed;
	top: 85%;
	left: 50%;
	width: $width;
	height: $height;
	margin-left: -$width / 2;
	padding: 1rem;
	transform: rotate(-2deg);
	z-index: 0;
	background-color: #ddd;
	color: #181818;
	box-shadow: 0 0 16px rgba(0,0,0,.25);
	transition: all .75s;
}


// Card deck

%first-card-in-deck {
	transform: rotate(2deg);
	z-index: 2;
	background-color: #fff;
}

%second-card-in-deck {
	z-index: 1;
	transform: rotate(0);
	background-color: #eee;
}

.card-checkbox:first-of-type + .card {
	@extend %first-card-in-deck;
}

.card-checkbox:nth-of-type(2) + .card {
	@extend %second-card-in-deck;
}


// Active card

.card-checkbox:checked + .card {
	margin-top: -240px;
	transform: rotate(0);
	top: 50%;
	background-color: #fff;
}


// Modify deck when certain cards are active so that the deck looks always the same (except if there isn't enough cards)

.card-checkbox:first-of-type:checked ~ .card-checkbox:nth-of-type(2) + .card {
	@extend %first-card-in-deck;
}

.card-checkbox:first-of-type:checked ~ .card-checkbox:nth-of-type(3) + .card {
	@extend %second-card-in-deck;
}

.card-checkbox:nth-of-type(2):checked ~ .card-checkbox:nth-of-type(3) + .card {
	@extend %second-card-in-deck;
}


// Navigation

#nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	padding-left: 0;
	list-style: none;
	font-size: .95rem;
	color: #686868;
	
	li:not(.lowercase) { text-transform: uppercase; }
	
	label {
		display: block;
		padding: .75rem 1.25rem;
		cursor: pointer;
		transition: color .25s;
		
		&:hover {
			color: #f8f8f8;
		}
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console