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


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


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.


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.


                <div id="tilt">
  <!--  Container for our block  -->



                html {
 display: flex;
  justify-content: center;
  align-items: center;
  align-contents: center;
  height: 100%;

/* Styles for the tilt block */
#tilt {
  display: block;
  height: 200px;
  width: 300px;
  background-color: grey;
  margin: 0 auto;
  transition: box-shadow 0.1s, transform 0.1s;
    * Adding image to the background
    * No relation to the hover effect.
  background-image: url(;
  background-size: 100%;
  background-repeat: no-repeat;

#tilt:hover {
  box-shadow: 0px 0px 30px rgba(0,0,0, 0.6);
  cursor: pointer;



                /* Store the element in el */
let el = document.getElementById('tilt')

/* Get the height and width of the element */
const height = el.clientHeight
const width = el.clientWidth

  * Add a listener for mousemove event
  * Which will trigger function 'handleMove'
  * On mousemove
el.addEventListener('mousemove', handleMove)

/* Define function a */
function handleMove(e) {
    * Get position of mouse cursor
    * With respect to the element
    * On mouseover
  /* Store the x position */
  const xVal = e.layerX
  /* Store the y position */
  const yVal = e.layerY
    * Calculate rotation valuee along the Y-axis
    * Here the multiplier 20 is to
    * Control the rotation
    * You can change the value and see the results
  const yRotation = 20 * ((xVal - width / 2) / width)
  /* Calculate the rotation along the X-axis */
  const xRotation = -20 * ((yVal - height / 2) / height)
  /* Generate string for CSS transform property */
  const string = 'perspective(500px) scale(1.1) rotateX(' + xRotation + 'deg) rotateY(' + yRotation + 'deg)'
  /* Apply the calculated transformation */ = string

/* Add listener for mouseout event, remove the rotation */
el.addEventListener('mouseout', function() { = 'perspective(500px) scale(1) rotateX(0) rotateY(0)'

/* Add listener for mousedown event, to simulate click */
el.addEventListener('mousedown', function() { = 'perspective(500px) scale(0.9) rotateX(0) rotateY(0)'

/* Add listener for mouseup, simulate release of mouse click */
el.addEventListener('mouseup', function() { = 'perspective(500px) scale(1.1) rotateX(0) rotateY(0)'