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

              
                <!-- basado backface-visibility https://css-tricks.com/almanac/properties/b/backface-visibility/ -->

<div id="perspectiva">
        <div id="contenedor">
            <div class="cara frontal">
                <h1>Mr. Codepen<br><span>Scroll ↓</span></h1>
            </div>
            <div class="cara trasera">
                <div id="abrir"></div>
                <div id="partes"></div>
                <div id="carta">
                    <hgroup>
                        <h1>Scroll</h1>
      									<h2>↓</h2>
                    </hgroup>
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit.</p>
                </div>
            </div>
        </div><!-- fin contenedor -->
</div>
<div id="wrapper"></div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Bad+Script);

*{
  margin: 0;
  padding: 0;
}

html, body{
  height: 100%;
}

body{
	font-family: 'Bad Script', cursive;
	-webkit-font-smoothing: antialiased;
}

#wrapper{
	background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,hsla(0,63%,57%,1)), color-stop(100%,hsla(0,84%,33%,1)));
	background: -webkit-radial-gradient(center, ellipse cover, hsla(0,63%,57%,1) 0%,hsla(0,84%,33%,1) 100%);
	width: 100%;
	height: 2000px;  
}

#perspectiva{
	position:fixed;
	top:200px;
	left:50%;
	margin-left: -200px;
	perspective:1000;
}

#contenedor{
	box-shadow: 0px 2px 10px hsla(0,0%,10%,1);
	width: 400px;
	height: 280px;
	transform-style: preserve-3d;
}

.cara{
	position: absolute;
	top:0;
	left:0;
	width: 100%;
	height: 100%;
	backface-visibility:hidden;
}

.frontal{
	background: -webkit-linear-gradient(top, hsla(54,4%,85%,1) 0%,hsla(54,0%,96%,1) 50%,hsla(54,4%,80%,1) 100%);
	z-index: 20;
}

.frontal h1{
	color: hsla(0,0%,20%,1);
	text-shadow: 0px 1px 1px hsla(0,0%,100%,1);
	font-size: 1em;
	text-align: center;
	margin-top: 110px;
}

.frontal h1 span{
	color: hsla(0,0%,50%,1);
	text-shadow: 0px 1px 1px hsla(0,0%,100%,1);
	font-size: .8em;
	text-align: center;
}

.trasera{
	background: -webkit-linear-gradient(top, hsla(54,0%,96%,1) 0%, hsla(54,0%,56%,1) 100%);
	transform:rotateY(-180deg);
}

#abrir{
	position: absolute;
	top:0;
	left:0;
	height: 0;
	width: 80px;
	border-top: 175px solid hsla(0,0%,85%,1);
	border-left: 160px solid transparent;
	border-right: 160px solid transparent;
  transform-origin:center top;
	z-index: 10;
}

#partes{
	position: absolute;
	top:0px;
	left:0px;
	width: 0;
	height: 0;
	border-left: 200px solid hsla(0,0%,90%,1);
	border-top: 140px solid transparent;
	border-bottom: 140px solid transparent;
	z-index: 5;
}

#partes:after{
	content: "";
	position: absolute;
	bottom:-140px;
	left:-200px;
	height: 0;
	width: 80px;
	border-bottom: 175px solid hsla(0,0%,95%,1);
	border-left: 160px solid transparent;
	border-right: 160px solid transparent;
}

#partes:before{
	content: "";
	position: absolute;
	top:-140px;
	right:-200px;
	width: 0;
	height: 0;
	border-right: 200px solid hsla(0,0%,90%,1);
	border-top: 140px solid transparent;
	border-bottom: 140px solid transparent;
}

#carta{
	background: -webkit-linear-gradient(top, hsla(54,0%,96%,1) 0%,hsla(0,0%,98%,1) 70%,hsla(0,0%,95%,1) 100%);
	box-shadow: 0px 2px 5px hsla(0,0%,10%,1);
	border-radius: 5px;
	position: absolute;
	top:3px;
	left:0;
	margin: 0 0 0 5px;
	width: 390px;
	height: 200px;
	overflow: hidden;
	z-index: 1;
}

#carta hgroup{
	margin-top:20px;
}

#carta hgroup h1{
	font-size: 1.6em;
	color: hsla(0,0%,70%,1);
	text-align: center;
	text-shadow: 0px 2px 1px hsla(0,0%,100%,1);
}

#carta hgroup h2{
	font-size: 1em;
	color: hsla(0,63%,57%,1);
  margin-top:-20px;
	text-align: center;
	text-shadow: 0px 1px 1px hsla(0,0%,100%,1);
}

#carta p{
	color: hsla(0,0%,20%,1);
	text-shadow: 0px 1px 1px hsla(0,0%,100%,1);
	font-size: 0.85em;
	line-height:1.45em;
	margin: 30px 50px 0 50px;
}

#carta p:first-letter{
	color: hsla(0,63%,57%,1);
	text-shadow: 0px 2px 1px hsla(0,0%,100%,1);
	font-size: 2.5em;
	float: left;
	line-height:1.2em;
	padding:10px 10px 0 0;
}
              
            
!

JS

              
                // autor: Marco Barría

 $(window).scroll(function () {   
       var scr = $(window).scrollTop(),
       		C = $('#contenedor'),
  	  		A = $('#abrir'),
  	  		E = $('#carta'),
					F = $('#carta hgroup h2'),
  	  		P = $('#perspectiva');
    
    	// giro y abertura
     	if (scr >= 100) {
				C.css({
					'transition':'all 1s',
					'transform':'rotateY(180deg)'
				});
				A.css({
					'transition':'all 1s .5s',
					'transform':'rotateX(180deg)',
					'z-index': '0'
				});
     	}
     	// cerrado y giro
     	else if (scr <= 100) {
				C.css({
					'transition':'all 1s .5s',
					'transform':'rotateY(0deg)'
				});
				A.css({
					'transition':'all 1s',
					'transform':'rotateX(0deg)',
					'z-index': '10'
				});  
     	}
     	// Sobre trasladoY / carta
     	if (scr >= 500) {
				E.css({
					'transition':'all .5s 1s',
					'top':'-550px',
					'height':'500px'
				});
     		P.css({
     			'transition':'all 1s',
     			'transform':'translateY(450px)'
     		});
				F.css({
     			'transition':'all 1s',
     			'transform':'rotateZ(180deg)'
				});
     	}
     	// Sobre position original / guardado carta
     	else if (scr <= 500) {
				E.css({
					'transition':'all .5s',
					'top':'3px',
					'height':'200px'
				});
     		P.css({
     			'transform':'translateY(0px)'
     		});
				F.css({
     			'transform':'rotateZ(0deg)'
				});
     	}
    });
              
            
!
999px

Console