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="container">
	<h1 class="with-pointer">This is a Title</h1>
	<h1 class="with-pointer pointer-top">This is a Different Pointer Title</h1>
	<h1>This is a Title Without a Pointer</h1>
	<h2 class="with-pointer">Yeah, you can use with (almost) any tag</h1>
	<div class="with-pointer">Of Course!</div>
	<h3 class="with-pointer">Another Title</h3>
	<h1 class="with-pointer">Also works with long titles without any problem</h3>
	<h1 class="with-pointer pointer-top">Also works with long titles with .pointer-top class</h3>
	<p class="with-pointer">Feel free to use/fork. But don't forget to thank <a href="" target="_blank">Dilara</a> for this idea.</p>


                html {
			font-size: 10px;
   		height: 100%;
body {
			font-family: 'Open Sans Condensed', sans-serif;
			margin: 0;
			color: #efefef;
			background: #232323;
			font-size: 1.33rem;
			display: flex;
			align-items: center;
   		justify-content: center;
   		height: 100%;
   		min-height: 40rem;
	h1 {
			text-transform: uppercase;
			font-size: 4rem;
	h2 {
			font-size: 3rem;
	h3 {
			font-size: 2rem;
	h1,h2,h3,h4,h5 {
			font-weight: normal;
	#container {
			width: 51rem;
			height: 35rem;
			overflow: auto;
			padding-left: 2rem;
			border-left: 1px solid white;
	.transition {
		    transition: .33s ease-out;
	.with-pointer > .pointer {
		    position: absolute;
		    border-radius: .8rem;
		    width: 1.5rem;
		    height: 1.5rem;
		    left: 0;
		    top: 0;
		    box-sizing: border-box;
		    border: .4rem solid rgba(255, 255, 255, .5);
		    background: #fff;
		    background-clip: padding-box;
		    transition-property: transform;
		    will-change: top, left;
	.pointer:hover {
		    transform: scale(1.33);
		    cursor: pointer;
	.pointer.init {
		    transform: scale(0);
	a:link, a:visited {
			font-weight: bold;
			text-decoration: none;
			font-size: 1.5rem
		/*	I really like to use rem values, don't I?	*/


                $(document).ready(function(e) {
    		var FS              = parseFloat($('html').css('font-size')),
    			container     	= $('#container'),
	    		withPointers	= $('.with-pointer'),
		        pointerTop 		= 0,
		        pointerLeft		= 0,
		        pointerBottom   = 0;

		    //	This updates the limit values for the pointers
		    function calculatePointerVariables() {
		        pointerTop    = container.offset().top;
		        pointerBottom = container.offset().top + container.outerHeight();
		        pointerLeft   = container.offset().left;

		        withPointers.each(function(i) {
		            handlePointerPosition($(this), true, i);

		    //	This moves a pointer (elm),
		    //	and removes .init if this is for the initial positioning (isInıt)
		    //	and uses pointer's index number (idx, not required)
		    function handlePointerPosition(elm, isInit, idx) {
		        var pointer = elm.children('.pointer'),
		            outerH  = pointer.get(0).offsetHeight,
		            outerW  = pointer.get(0).offsetWidth,
		            atTop   = elm.hasClass('pointer-top');

		        //	If there is no idx, find it for this elm pointer.
		        if(idx == undefined) idx = withPointers.index(elm);

		        //	Calculate maximum points and new top value (and if this has a .pointer-top move it up a little bit)
		        var thisMaxTop    = pointerTop + (idx * (outerH + FS / 3)),
		            thisMaxBottom = pointerBottom - ((withPointers.length - 1 - idx) * (outerH + FS / 3) + outerH),
		            newTop 		  = elm.offset().top + (!atTop ? elm.height() / 2 - outerH / 2 : outerH);
		        //	Clamp the new top value between max top/bottom values
		        newTop = Math.clamp(newTop, thisMaxTop, thisMaxBottom);

		        	'top': newTop,
		        	'left': pointerLeft - outerW/2

		        //	So, you say, all these calculations were for the initial position? OK, let me handle that, so you can see the pointers (with a little effect)
		        if(isInit) {
		            setTimeout(function() {
		            }, (idx * 67) + 10);

		    //	Yeah, the pointers will be updated on scrolling
		    container.on('scroll', function(e) {
		        withPointers.each(function() {handlePointerPosition($(this));});

		    //	Resize? No problemo! This'll take care of everything.
		    $(window).on('resize', function() {
		    	//	First, set pointers to theirs .init
		        //	Then, calculate new values
		        setTimeout(function() {calculatePointerVariables();}, 555);

		    //	Listen for a .pointer click to scroll to it's parent.
		    $(this).on('click', '.pointer', function() {
		        var t      = $(this),
		            parent = t.closest('.with-pointer');

		        	scrollTop: parent.position().top - container.position().top + container.scrollTop() + parseInt(parent.css('margin-top'))

		    //	Prepare .with-pointers' pointers
        	//	Just wait a little for the init
        	setTimeout(function(){calculatePointerVariables();}, 195);

    	//	This looks so cool!
    	$.fn.renderPointer = function() {
	        this.each(function() {
	            var t = $(this);

	            if(t.find('.pointer').length == 0) {
	                t.prepend('<div class="pointer transition init" title="' + t.text() + '"></div>');

			Clamping function
	    (function() {
            Math.clamp = function(a, b, c) {
                return Math.max(b, Math.min(c, a));