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

              
                <div id="app">
	<div class="item item-one">
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon">
    <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
</svg>
	</div>
	<div class="item item-two">
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun">
    <circle cx="12" cy="12" r="5"/>
    <path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/>
</svg>
	</div>
	<div class="item item-three">
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star">
    <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
</svg>

	</div>
	<div class="item item-four">
		<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-activity">
    <path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
</svg>

	</div>
</div>
              
            
!

CSS

              
                body, html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: #feffdf;
  display: flex;
  justify-content: center;
  align-items: center;
	font-family: monospace;
}

#app {
	display: flex;
	flex-wrap: wrap;
	flex-direction: row;
	justify-content: center;
	align-items: center;
  height: 87vh;
  width: 46vh;
  transform: scale(0.8);
  border-radius: 2rem;
  background-color: #ef5a5a;
	color: #fff;
  box-shadow: 0px 2vh 10vh rgba(0,0,0,.3);
  overflow: hidden;
  border: 1vh solid #F0F0F0;
	box-sizing: border-box;
	padding: 20px;
}

.item {
	margin: 20px;
	flex: 0 0 35%;
	
	svg {
		width: 100%;
		height: auto;
	}
	
	&-one {
		transform: rotate(calc(var(--x) * 360deg));
	}
	
	&-two {
		transform: scale(calc(calc(var(--x) * 0.5) + 1));
	}
	
	&-three {
		opacity: calc(var(--x) + 1);
	}
	
	&-four {
		transform: translateX(calc(var(--x) * 10px));
	}
}

              
            
!

JS

              
                const frame = document.querySelector('#app');
let raf; 

document.addEventListener('mousemove', (e) => {
  raf = raf || requestAnimationFrame(() => update(e));
});

function update(e){
	const x =  ((e.clientX / window.innerWidth) - 0.5) * 2;
  frame.style.setProperty('--x', x );
  raf = null;
}


              
            
!
999px

Console