123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <article id="parallax">
 
  <h1 >Semantic Parallax with CSS </h1>
  <p>By Christian Landgren, Iteam</p>
  <p><code>.above1{-webkit-transform: translateZ(100px)}
.above2{-webkit-transform: translateZ(200px)}
.under1{-webkit-transform: translateZ(-100px)}
.under2{-webkit-transform: translateZ(-200px)} 
    
window.onscroll = function(){
    document.body.style.webkitPerspectiveOrigin =
    window.scrollX + "px " + 
    window.scrollY + "px";
}</code></p>
  
  <img src="http://www.iutopi.com/img/capa1b.png" class="under1">
  
  
  <h3>Parallax scroll with CSS semantics</h3>
  <p class="intro">Achieve a realistic 3D feeling on your web page with just one line of Javascript. Instead of manually moving elements with javascript we use CSS3 perspective origin to move all layers at the same time. This requires approach only requires one* row of javascript.</p>
  <img src="http://www.iutopi.com/img/capa1b.png" class="under2 right">
  <p>
    Supports both vertical and horizontal scrolling. Not working yet on iOS but traditional methods isn't working either, Android unkown. Gracefully downgrades for non supported devices. Of course you should add the vendor specifics for all queries. I left them out for readability in theese examples.</p>
    <img src="http://www.iutopi.com/img/capa1b.png" class="over3 ">
  
  <h2>Getting started</h2>
  <p>
    Add this row of Javascript to your site code
    <code>&lt;script&gt;
  window.onscroll = function(){
    document.body.style.webkitPerspectiveOrigin =
    window.scrollX + "px " + 
    window.scrollY + "px";
  }
&lt;/script&gt;</code>
    
     Add these to your CSS
    <code>&lt;style&gt;
  body{
    -webkit-perspective: 500;
    -webkit-perspective-origin: 0 0;
  }
  .over1 {
    position:absolute;
    -webkit-transform: translateZ(100px);  
  }

  .over2 {
    position:absolute;
    -webkit-transform: translateZ(200px);  
  }

  .over3 {
    position:absolute;
    -webkit-transform: translateZ(300px);  
  }

  .over4 {
    position:absolute;
    -webkit-transform: translateZ(400px);  
  }

  .under1 {
    position:absolute;
    -webkit-transform: translateZ(-100px);  
  }

  .under2 {
    position:absolute;
    -webkit-transform: translateZ(-300px);  
  }

  .under3 {
    position:absolute;
    -webkit-transform: translateZ(-400px);  
  }

  .under4 {
    position:absolute;
    -webkit-transform: translateZ(-600px);  
  }
&lt;/style&gt;</code>
    
    <h2>Be creative:</h2>
    <code>&lt;img src="..." class="over3 "&gt;
&lt;img src="..." class="under3"&gt;
&lt;img src="..." class="under1"&gt;
    </code>
    
    <h2>Add real 3D objects:</h2>
    <code>&lt;img src="..." style="-webkit-transform:rotateX(25deg); "&gt;
    </code>
  
  <img src="https://maps.googleapis.com/maps/api/staticmap?markers=tegnérgatan%2028,stockholm&zoom=15&size=600x600&sensor=false" style="-webkit-transform:rotateX(60deg); border-radius: 600px; margin-bottom: -200px; box-shadow: 20px 10px rgba(0,0,0,0.5); width: 300px; height: 300px;"/>
  
  </p>
  
  
  <p>By combining animation and other 3D CSS transform you can easily get a 3D interface without having any more javascript code at all. The perspective depth that is added with this trick really enhances the 3D experience for the user.</p>

  
<p>Follow me on <a href="https://twitter.com/landgren">Twitter</a> and <a href="https://github.com/irony">Github</a></p>
  <img src="http://www.iutopi.com/img/capa5b.png" class="under1 shark right" >

  <img class="background under4" src="http://www.iutopi.com/img/bloque1.jpg" >


<p style="margin-top: 500px">All illustrations are copyrighted and used here with kind approval of <a href="http://iutopi.com">iutopi.com</a> </p>

</article>
            
          
!
            
              body{
  -webkit-perspective: 600;
  -webkit-perspective-origin: 0 0;
}

.over1{
  position:absolute;
  -ms-transform: translateZ(100px);
  -moz-transform: translateZ(100px);
  -webkit-transform: translateZ(100px);
  z-index:100;
}

.over2{
  position:absolute;
  -ms-transform: translateZ(200px);
  -moz-transform: translateZ(200px);
  -webkit-transform: translateZ(200px);
  z-index:200;
}

.over3{
  position:absolute;
  -ms-transform: translateZ(300px);
  -moz-transform: translateZ(300px);
  -webkit-transform: translateZ(300px);
  z-index:300;
}

.under1{
  position:absolute;
  -ms-transform: translateZ(-100px);
  -moz-transform: translateZ(-100px);
  -webkit-transform: translateZ(-100px);
  z-index:-100;
}

.under2{
  position:absolute;
  -ms-transform: translateZ(-300px);
  -moz-transform: translateZ(-300px);
  -webkit-transform: translateZ(-300px);
  z-index:-300;
}

.under3{
  position:absolute;
  -ms-transform: translateZ(-400px);
  -moz-transform: translateZ(-400px);
  -webkit-transform: translateZ(-400px);
  z-index:-400;
}

.under4{
  position:absolute;
  -ms-transform: translateZ(-600px);
  -moz-transform: translateZ(-600px);
  -webkit-transform: translateZ(-600px);
  z-index:-600;
}


/* SITE */


body{
  font-family: Helvetica Neue;
  font-weight: 100;
  font-size: 1.2em;
  line-height: 120%;
  background: #001929;
  color: #fff;
}

a, a:active, a:visited{
  color: #eee;
  font-style: italic;
  text-decoration: none;
}

.intro{
  padding-top:400px;
  font-size: 1.4em;
  line-height: 150%;
  letter-spacing: 1px;
}

.right
{
  right:0;
}

article img.background{
  width: 400%;
  margin-left:-40%;
  position:absolute;
  top:0;
  left:0;
  z-index:-800;
}

article img.shark:hover{
  -webkit-transition: all 4s easeOut;
  -webkit-transform: rotateX(-180deg);
}

article h1{
    -webkit-transform: translateZ(10px);
  z-index:10;
  font-size:40px;
}

article h2{
  -webkit-transform: translateZ(10px);
  z-index:10;
}

article{
  padding:100px 0 0 200px;
}

article p, article code{
  -webkit-transform: translateZ(30px);
  z-index:10;
  padding: 50px 0;
}

article code{
 white-space: pre-wrap;
 display: block;
 padding: 0.5em 1em;
 margin: 1em 0;
 border-left: 1px solid #bebab0;
  color: #fff;
 overflow: scroll;
}


            
          
!
            
               window.onscroll = function(){
   
         document.body.style.msPerspectiveOrigin =
         document.body.style.mozPerspectiveOrigin =
         document.body.style.webkitPerspectiveOrigin =
         window.scrollX + "px " + 
         window.scrollY + "px";
       }
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console