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.


                <p>Click anywhere in the gray area below to see the red square move to the position of your click.</p>

<div id="contentContainer">
  <div id="thing">
<!-- This snippet is inspiried by code from Kirupa:
I have replaced the loop over all element-offsets by the function:
Since IE does not support scrollLeft and scrollTop for the body correctly, this is helpful (body is the last element in Kirupa's loop). On the other hand wide borders need to be considered in the code when needed. Have fun with it, Rene -->


                #contentContainer {
	position: relative;
	width: 500px;
	height: 300px;
	border: 1px black solid;
	overflow: hidden;
	background-color: #EEE;
	cursor: pointer;
#thing {
	position: relative;
	left: 50px;
	top: 50px;
	transition: left .5s cubic-bezier(.42,-0.3,.78,1.25), 
			top .5s cubic-bezier(.42,-0.3,.78,1.25);


                var theThing = document.querySelector("#thing");
var container = document.querySelector("#contentContainer");

container.addEventListener("click", function(event) {
	var xPosition = event.clientX - container.getBoundingClientRect().left - (theThing.clientWidth / 2);
	var yPosition = event.clientY - container.getBoundingClientRect().top - (theThing.clientHeight / 2);
	// in case of a wide border, the boarder-width needs to be considered in the formula above = xPosition + "px"; = yPosition + "px";