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

              
                <h1 class="page-title">Receipt with 3D fold effect</h1>

<article class="receipt">
	<section class="receipt__half upper">
		<p>Receipt</p>
		<h1>$59.98</h1>
		<p class="sm">04.06.2019 - 09:47</p>
		
		<div class="receipt__content">
			<table>
				<tbody>
					<tr>
						<td>Faded jeans</td>
						<td>$39.99</td>
					</tr>
					<tr>
						<td>Sleeveless shirt</td>
						<td>$19.99</td>
					</tr>
				</tbody>
			</table>
		</div>
	</section>
	
	<section class="receipt__half lower">
		<button>More info</button>
	</section>
</article>


              
            
!

CSS

              
                $bg-body: #f4f4f4;
$bg: white;
$upper-height: 140px;
$trs-time: .8s;
$trs-time-sm: .35s;
$trs-ease: ease;

html {   box-sizing: border-box; } *, *:before, *:after {   box-sizing: inherit; }

body {
	margin: 40px;
	background: $bg-body;
}

.receipt {
	width: 400px;
	max-width: 100%;
	margin: auto;
	position: relative;
}

// Shared receipt half styles
.receipt__half {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	width: 100%;
	
	position: relative;

	background: $bg;
	perspective: 1000px;

	&::after {
		content: '';
		
		display: block;
		width: 100%;
		height: 100px;
		
		position: absolute;
    left: 0;
				
    backface-visibility: hidden;
		transition: all $trs-time $trs-ease;
		transition-delay: $trs-time-sm;
	}
	
	.active & {
		&::after {
			transition-delay: 0s;
		}
	}
}

// Upper half
.upper {
	padding: 20px;
	z-index: 10;
	
	&::after {
		top: 100%;

		background: darken($bg, 3%);
		border-top: 1px dashed #dedede;
		
		transform: rotate3d(1, 0, 0, -90deg);
    transform-origin: top center;
	}
	
	.active & {
		&::after {
			background: $bg;
			transform: rotate3d(1, 0, 0, 0deg);
		}
	}
}

// Lower half
.lower {
	transition: transform $trs-time $trs-ease;
	transition-delay: $trs-time-sm;
	
	&::after {
		bottom: 100%;
		
		background: darken($bg, 8%);
		
    transform: rotate3d(1, 0, 0, 90deg);
    transform-origin: bottom center;
	}
	
	.active & {
		border-top: none;
		
		transform: translateY(200px);
		transition-delay: 0s;
		
		&::after {
			background: $bg;
			transform: rotate3d(1, 0, 0, 0deg);
		}
	}
}

// Text styles
h1 {
	margin: 10px 0 20px;	
	
	&.page-title {
		text-align: center;
		margin-bottom: 60px;
	}
}

p {
	margin: 0; 
	
	&.sm {
		font-size: 80%;
	}
}

// Button
button {
	$color: #888;
	
	width: 100%;
	padding: 15px 20px;
	
	background: none;
	outline: none;
	border: none;
	border-top: 1px dashed #dedede;
	
	color: $color;
	font-size: 90%;
	font-weight: 600;
	
	cursor: pointer;
	transition: all $trs-ease $trs-time-sm;
	
	&:hover {
		color: darken($color, 25%);
	}
}

// Receipt content
.receipt__content {
	display: flex;
	align-items: center;
	width: 100%;
	height: 200px;
	padding: 20px;
	
	position: absolute;
	top: $upper-height;
	left: 0;
	z-index: 20;
	
	pointer-events: none;
	opacity: 0;
	transform: translateY(-8px);
	transition: opacity $trs-ease $trs-time-sm, transform $trs-ease $trs-time-sm;
	transition-delay: 0s;
	
	.active & {
		opacity: 1;
		transform: translateY(0);
		transition-delay: $trs-time;
	}
}

table {
	width: 100%;
}

tr {
	display: flex;
	justify-content: space-between;
	margin: 10px 0;
}
              
            
!

JS

              
                const receipt = document.querySelector('.receipt')
const button = document.querySelector('button')

const toggleReceipt= () => {
	receipt.classList.toggle('active')
	
	if(receipt.classList.contains('active')) {
		button.innerHTML = 'Less info'
	} else {
		button.innerHTML = 'More info'
	}
}

button.addEventListener('click', toggleReceipt)
              
            
!
999px

Console