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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

            
              <html>
  <head>
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro|PT+Mono" rel="stylesheet">
  </head>
  <body>
    <h1 class="writing">Parallax effect behind an image cutout: CSS + SVG</h1>
    <div class="writing">
      <p>Please note: This works on desktop/laptop, but not on mobile. I'm working on that!</p>
      <p>Steps:</p>
      <ul>
        <li>Make an SVG cutout of the same background color as your background.</li>
        <li>Make a parallax background with CSS. Use the same proportions as your SVG.</li>
        <li>Place an <span class="code">img</span> of your SVG inside the HTML for your parallax <span class="code">div</span>.</li>
        <li>Align and size parallax background as you like. Don't forget to make things responsive!</li>
        <li>Enjoy!</li>
      </ul>
      <p>Please note, the winking brain is my personal logo and my exclusive copyright. The Oregon grape (not real grapes!) image is my photo, available via Creative Commons on <a href="https://www.flickr.com/photos/alexfiles/4939918772/in/album-72157613801929264/" target="_blank">Flickr</a>.
      
    </div>
    
    <div class="background-oregon-grapes">
       <img src="https://aeoneal.com/imagery/brain-reverse-cutout.svg">
    </div>
      
      
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  </body>
</html>
            
          
!

CSS

            
              /* general CSS, unrelated to parallax or img */
body {
  background: #fff;
  color: #222;
  font-family: 'Source Sans Pro', sans-serif;
}
.code {
  font-family: 'PT Mono', serif;
  color: #090;
}
.writing {
  width: 74%;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 560px) {
  .writing {
    width: 96%;
  }
}

/* Parallax CSS */
.background-oregon-grapes {
  background-image: url("http://aeoneal.com/imagery/blog/oregon-grapes.jpg");
  background-size: 100%;
  height: 560px;
  width: 560px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 767px) {
  .background-oregon-grapes {
    height: 330px;
    width: 330px;
  }
}


/* Image CSS for your SVG */
img {
  height: 100%;
  width: 100%;
}

            
          
!

JS

            
              
            
          
!
999px

Console