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

              
                <!-- 
For CSS Grid expertise:
Rachel Andrew: https://gridbyexample.com/
Jen Simmons: http://labs.jensimmons.com/
 -->
<div id="holder">
  <div id="left">
    <div id="grid">
      <img src="https://assets.codepen.io/881020/t1.jpg" />
      <img src="https://assets.codepen.io/881020/t2.jpg" />
      <img src="https://assets.codepen.io/881020/t3.jpg" />
      <img src="https://assets.codepen.io/881020/t4.jpg" />
      <img src="https://assets.codepen.io/881020/t5.jpg" />
      <img src="https://assets.codepen.io/881020/t6.jpg" />
      <img src="https://assets.codepen.io/881020/t7.jpg" />
      <img src="https://assets.codepen.io/881020/t8.jpg" />
      <img src="https://assets.codepen.io/881020/t9.jpg" />
      <img src="https://assets.codepen.io/881020/t10.jpg" />
      <img src="https://assets.codepen.io/881020/t11.jpg" />
      <img src="https://assets.codepen.io/881020/t12.jpg" />
      <img src="https://assets.codepen.io/881020/t13.jpg" />
      <img src="https://assets.codepen.io/881020/t14.jpg" />
      <img src="https://assets.codepen.io/881020/t15.jpg" />
      <img src="https://assets.codepen.io/881020/t16.jpg" />
      <img src="https://assets.codepen.io/881020/t17.jpg" />
      <img src="https://assets.codepen.io/881020/t18.jpg" />
      <img src="https://assets.codepen.io/881020/t19.jpg" />
      <img src="https://assets.codepen.io/881020/t20.jpg" />
      <img src="https://assets.codepen.io/881020/t21.jpg" />
      <img src="https://assets.codepen.io/881020/t22.jpg" />
      <img src="https://assets.codepen.io/881020/t23.jpg" />
      <img src="https://assets.codepen.io/881020/t24.jpg" />
      <img src="https://assets.codepen.io/881020/t25.jpg" />
    </div>
    <p id="toggle">Toggle Grid Lines</p>
  </div>
  <div id="text">
    <h1>Orange</h1>
    <p>I once had a book full of amazing Macromedia Flash experiments, one of which was an image of the Mona Lisa that would morph as you moved the mouse over it.</p>
    <p>And as @LawrieCape kindly reminded me in the comments, it was by Yugo Nakamura in "New Masters of Flash".</p>
    <p>Anyway, this is my version of that experiment using CSS Grid to morph the image.</p>
  </div>
</div>

              
            
!

CSS

              
                body {
  color: #FFFCF2;
  background-color: #ff6600;
  font-family: Helvetica, Arial, Sans-Serif;
  text-align: center;
}
h1 {
  margin-top: 2vh;
  font-size: 1.8em;
}
p {
  margin-top: 2vh;
  font-size: 1.2em;
}
#toggle{
  text-decoration: underline;
}

#holder {
  display: grid;
  grid-template-columns: 90vh 1fr;
  margin: 3vh 5vh 0 5vh;
  grid-gap: 2vh;
}

#grid {
  display: grid;
  width: 90vh;
  height: 90vh;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows:  1fr 1fr 1fr 1fr 1fr;
  grid-gap: 0;
}

img {
  width: 100%;
  height: 100%;
  -webkit-user-select:none;
  -webkit-touch-callout:none;
}
#left {
  width: 90vh;
}
#text {
  text-align: left;
  padding-bottom: 20px;
}
@media  (orientation:portrait) {
  #holder {
    grid-template-columns: 1fr;
  }
  #grid {
    width: 90vw;
    height: 90vw;
  }
  #left {
    width: 90vw;
  }
}
              
            
!

JS

              
                var lines = false;
$("#grid").mousemove(function( event ) {
  var leftPer = (event.clientX - $("#grid").offset().left)/$("#grid").width();
  var topPer = (event.clientY - $("#grid").offset().top)/$("#grid").height();
  console.log(leftPer);
  console.log(topPer);
  console.log("--------");
  colStr = "";
  rowStr = "";
  for(i=0;i<5;i++){
    nearX = 1 - (Math.abs(leftPer - (0.1+0.2*i)));
    colStr += " " +  (1 + Math.pow(nearX*5,2))  + "fr";
  }
  for(j=0;j<5;j++){
    nearY = 1 - (Math.abs(topPer - (0.1+0.2*j)));
    rowStr += " " + (1 + Math.pow(nearY*5,2)) + "fr";
  }
  console.log(colStr);
  console.log(rowStr);
//  $("#grid").css('grid-template-rows', rowStr);
  $("#grid").css('grid-template-columns', colStr);
});
$("#grid").mouseout(function() {
  $("#grid").css('grid-template-rows', "1fr 1fr 1fr 1fr 1fr");
  $("#grid").css('grid-template-columns', "1fr 1fr 1fr 1fr 1fr");
});
$("#toggle" ).click(function() {
  if(lines){
    lines=false;
    $("#grid").css('grid-gap', "0");
  }else{
    lines=true;
    $("#grid").css('grid-gap', "1px");
  }
});
              
            
!
999px

Console