Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <svg style="display: none;" xmlns="http://www.w3.org/2000/svg"><symbol id="codepen-logo" viewBox="0 0 120 120"><path class="outer-ring" d="M60.048 0C26.884 0 0 26.9 0 60.048s26.884 60 60 60.047c33.163 0 60.047-26.883 60.047-60.047 S93.211 0 60 0z M60.048 110.233c-27.673 0-50.186-22.514-50.186-50.186S32.375 9.9 60 9.9 c27.672 0 50.2 22.5 50.2 50.186S87.72 110.2 60 110.233z"/><path class="inner-box" d="M97.147 48.319c-0.007-0.047-0.019-0.092-0.026-0.139c-0.016-0.09-0.032-0.18-0.056-0.268 c-0.014-0.053-0.033-0.104-0.05-0.154c-0.025-0.078-0.051-0.156-0.082-0.232c-0.021-0.053-0.047-0.105-0.071-0.156 c-0.033-0.072-0.068-0.143-0.108-0.211c-0.029-0.051-0.061-0.1-0.091-0.148c-0.043-0.066-0.087-0.131-0.135-0.193 c-0.035-0.047-0.072-0.094-0.109-0.139c-0.051-0.059-0.104-0.117-0.159-0.172c-0.042-0.043-0.083-0.086-0.127-0.125 c-0.059-0.053-0.119-0.104-0.181-0.152c-0.048-0.037-0.095-0.074-0.145-0.109c-0.019-0.012-0.035-0.027-0.053-0.039L61.817 23.5 c-1.072-0.715-2.468-0.715-3.54 0L24.34 46.081c-0.018 0.012-0.034 0.027-0.053 0.039c-0.05 0.035-0.097 0.072-0.144 0.1 c-0.062 0.049-0.123 0.1-0.181 0.152c-0.045 0.039-0.086 0.082-0.128 0.125c-0.056 0.055-0.108 0.113-0.158 0.2 c-0.038 0.045-0.075 0.092-0.11 0.139c-0.047 0.062-0.092 0.127-0.134 0.193c-0.032 0.049-0.062 0.098-0.092 0.1 c-0.039 0.068-0.074 0.139-0.108 0.211c-0.024 0.051-0.05 0.104-0.071 0.156c-0.031 0.076-0.057 0.154-0.082 0.2 c-0.017 0.051-0.035 0.102-0.05 0.154c-0.023 0.088-0.039 0.178-0.056 0.268c-0.008 0.047-0.02 0.092-0.025 0.1 c-0.019 0.137-0.029 0.275-0.029 0.416V71.36c0 0.1 0 0.3 0 0.418c0.006 0 0 0.1 0 0.1 c0.017 0.1 0 0.2 0.1 0.268c0.015 0.1 0 0.1 0.1 0.154c0.025 0.1 0.1 0.2 0.1 0.2 c0.021 0.1 0 0.1 0.1 0.154c0.034 0.1 0.1 0.1 0.1 0.213c0.029 0 0.1 0.1 0.1 0.1 c0.042 0.1 0.1 0.1 0.1 0.193c0.035 0 0.1 0.1 0.1 0.139c0.05 0.1 0.1 0.1 0.2 0.2 c0.042 0 0.1 0.1 0.1 0.125c0.058 0.1 0.1 0.1 0.2 0.152c0.047 0 0.1 0.1 0.1 0.1 c0.019 0 0 0 0.1 0.039L58.277 96.64c0.536 0.4 1.2 0.5 1.8 0.537c0.616 0 1.233-0.18 1.77-0.537 l33.938-22.625c0.018-0.012 0.034-0.027 0.053-0.039c0.05-0.035 0.097-0.072 0.145-0.109c0.062-0.049 0.122-0.1 0.181-0.152 c0.044-0.039 0.085-0.082 0.127-0.125c0.056-0.055 0.108-0.113 0.159-0.172c0.037-0.045 0.074-0.09 0.109-0.139 c0.048-0.062 0.092-0.127 0.135-0.193c0.03-0.049 0.062-0.098 0.091-0.146c0.04-0.07 0.075-0.141 0.108-0.213 c0.024-0.051 0.05-0.102 0.071-0.154c0.031-0.078 0.057-0.156 0.082-0.234c0.017-0.051 0.036-0.102 0.05-0.154 c0.023-0.088 0.04-0.178 0.056-0.268c0.008-0.045 0.02-0.092 0.026-0.137c0.018-0.139 0.028-0.277 0.028-0.418V48.735 C97.176 48.6 97.2 48.5 97.1 48.319z M63.238 32.073l25.001 16.666L77.072 56.21l-13.834-9.254V32.073z M56.856 32.1 v14.883L43.023 56.21l-11.168-7.471L56.856 32.073z M29.301 54.708l7.983 5.34l-7.983 5.34V54.708z M56.856 88.022L31.855 71.4 l11.168-7.469l13.833 9.252V88.022z M60.048 67.597l-11.286-7.549l11.286-7.549l11.285 7.549L60.048 67.597z M63.238 88.022V73.14 l13.834-9.252l11.167 7.469L63.238 88.022z M90.794 65.388l-7.982-5.34l7.982-5.34V65.388z"/></symbol></svg>


<div class="container"> 
  <h1>Lets Have Some Fun With Scrolling</h1>
  <div class="content-diagonal">
    <div class="content-block">
      <img src="https://placebear.com/400/400" alt="" />
      <p>We're going to scroll diagonally!</p>
    </div>
    <div class="content-block">
      <img src="https://placebear.com/500/500" alt="" />
      <p>Isn't this neat?</p>
    </div>
    <div class="content-block">
      <img src="https://placebear.com/600/600" alt="" />
      <p>Check out the css & js to see how it's acheived</p>
    </div>
    <div class="content-block">
      <img src="https://placebear.com/300/300" alt="" />
      <p>Wow, that's a lot of bears</p>
    </div>
    <div class="content-block">
      <img src="https://placebear.com/450/450" alt="" />
      <p>When does this thing end?</p>
    </div>
    <div class="content-block">
      <img src="https://placebear.com/500/500" alt="" />
      <p>OK, last one!</p>
    </div>
  </div>  
</div>
<footer>
  <div class="container">
    <p>Thanks for checking out the demo!</p>
    <p><a href="http://jacobharris.codes">jacobharris.codes</a></p>
    <a href="https://codepen.io/ahoy/" target="_blank" class="codepen">
      <svg class="logo">
        <use xlink:href="#codepen-logo"></use>
      </svg>
      &nbsp;ahoy
    </a>
  </div>
</footer>
              
            
!

CSS

              
                $spacer: 400px;

*{
  box-sizing: border-box;
}

body{
  background-color: #ffffff;
  background-image: url(http://jacobharris.codes/media/vsRawcK.jpg);
  background-attachment: fixed;
  background-size: cover;
  background-position: 50% -50%;
  overflow-x: hidden;
}

h1 {
  background-color: #e81c1d;
  padding:30px 30px;
  color: #ffffff;
}

p {
  // color: #e81c1d;
  color: #333;
  font-size: 24px;
  margin: 0;
  padding: 0 0px 15px 15px;
}

.container{
  max-width: 100%;
  width: 960px;
  padding: 45px 15px $spacer;
  margin: 0 auto;
  border-left: 5px solid #e81c1d;
  
  @media (min-width: 1200px){
    width: 1230px;
  }
}

.content-diagonal{
  padding-left: $spacer / 2;
  margin-top: $spacer / 4;
}
.content-block{
  width: $spacer * 2;
  height: $spacer;
  position: relative;
  display: flex;
  align-items: center;
  &:nth-child(2){
    margin-left: $spacer;
  }
  &:nth-child(3){
    margin-left: $spacer * 2;
  }
  &:nth-child(4){
    margin-left: $spacer * 3;
  }
  &:nth-child(5){
    margin-left: $spacer * 4;
  }
  &:nth-child(6){
    margin-left: $spacer * 5;
  }
  img {
    width: 400px;
    clip-path: circle(50% at 50% 50%);
  }
}

footer {
  background: #fceeed;
  padding: 0px 0;
  height: 100vh;
  display:flex;
  align-items: stretch;
  position: relative;
  p{
    padding: 100px 0;
  }

  a {
    color: #333;
    text-decoration: none;
    font-size: 24px;
    display:flex;
    align-items: center;
    
     svg{
      width:50px;
    }
  }
}


              
            
!

JS

              
                const container = document.querySelector('.content-diagonal');
const contentHeight = container.offsetHeight;
const numBlocks = container.querySelectorAll('.content-block').length;

window.addEventListener('scroll', function(){
  let haveScrolled = window.pageYOffset;
  let proportion = (haveScrolled / contentHeight);
  const toMove = "-" + (proportion * contentHeight) + "px";
  container.style.transform = "translateX("  + toMove + ")" ;
});
              
            
!
999px

Console