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="container">

<div class="highlight"></div>
	
<div class="outer">
	<div class="inner">
		<div class="icon">1</div>
		<div class="text">
			hello
		</div>
	</div>
</div>

<div class="outer">
	<div class="inner">
		<div class="icon">2</div>
		<div class="text">
			it&rsquo;s me
		</div>
	</div>
</div>

<div class="outer">
	<div class="inner">
		<div class="icon">3</div>
		<div class="text">
			I&rsquo;ve been wonderin&rsquo; somethin&rsquo; somethin&rsquo; me
		</div>
	</div>
</div>
	
	<div class="outer">
	<div class="inner">
		<div class="icon">4</div>
		<div class="text">
			hello from the outside
		</div>
	</div>
</div>
	
	<div class="outer">
		<div class="inner">
		<div class="icon">5</div>
		<div class="text">
			at least I can say that I tried
		</div>
	</div>
</div>
	
	<div class="outer">
		<div class="inner">
		<div class="icon">6</div>
		<div class="text">
			to get these lyrics right
		</div>
	</div>
</div>
	
</div>

              
            
!

CSS

              
                $umit: 40px;
$marg: 12px;
$t: .5s;
$bpx: 0px;
$bg: #7de8df;
$accent: #a8db18;

html,body{
	margin: 0;
	padding: 0;
	height: 100%;
}
body{
	display: flex;
	align-items: center;
	justify-content: center;
	background: $bg;
}

.inner{
	display: flex;
	align-items: center;
}

.text{
	white-space: nowrap;
	display: flex;
	align-items: center;
	padding-right: 2*$marg;
}

.icon{
	width: $umit - 2*$bpx;
	height: $umit - 2*$bpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.outer{
	display: flex;
	width: $umit;
	height: $umit;
	overflow: hidden;
	transition: $t;
	margin: $marg;
	border-radius: 1000px;
	border: $bpx solid rgba(0,0,0,.0);
	box-shadow: inset 0px 3px 3px 1px rgba(0,0,0,.08),inset 0px -1px 2px 1px rgba(255,255,255,.45);
	cursor: pointer;
}

*{
	flex-shrink: 0;
}

#container{
	display: inline-flex;
	position: relative;
	// background: #fafafa;
	border-radius: 1000px;
	box-shadow: inset 0px -2px 5px 0 rgba(0,0,0,.1),inset 0px 2px 5px 0 rgba(255,255,255,.5);
	background: rgba(255,255,255,.2);
}

#container::after{
	content: '';
	position: absolute;
	width: 100%;
	height: 10px;
	border-radius: 100%;
	bottom: 0px;
	box-shadow: 0 40px 20px 3px rgba(0,0,0,.13);
	transform: scaleX(1.05);
}

.highlight{
	height: $umit;
	width: $umit;
	position: absolute;
	z-index: 1;
	background: $accent;
	margin-top: $marg;
	left: $marg;
	transition: $t;
	border-radius: 1000px;
	border: 1px solid rgba(0,0,0,.1);
	box-shadow: inset 0 -5px 8px 0 rgba(0,0,0,.2),inset 0 5px 8px 0 rgba(255,255,255,.5), 0 1px 3px 0 rgba(0,0,0,.1);
}

.selected{
	width: initial;
}

.inner{
	position: relative;
}
.active .inner{
	z-index: 2;
}

*{
	font-family: "Heebo", sans-serif;
	color: white;
	font-weight: 700;
	box-sizing: border-box;
}

.icon{
	color: rgba(0,0,0,.4);
	font-weight: 900;
}

.text{
	text-shadow: 0 1px rgba(0,0,0,.4)
}

.outer:not(.active) .text{
	visibility: hidden;
}




              
            
!

JS

              
                const outers = Array.from(document.getElementsByClassName('outer'));
let active = null;
let queue = Promise.resolve();

const h = document.getElementsByClassName('highlight')[0];
const init = outers[0].style.width;

const u = outers[1].getBoundingClientRect().x - outers[0].getBoundingClientRect().x;

outers.forEach((o,i) => {
	o.dataset.idx = i;
	o.addEventListener('click', ()=>activate(o));
})

function activate(thing){
	if (active === thing) return;
	queue = queue.then(() => {
		return new Promise(r => {
			moveTo(thing);
			minimize(thing).then(()=>expand(thing)).then(r);
			active = thing;
			thing.classList.add('active');
		})
	})
}


function minimize(thing){
	if (!active) return Promise.resolve();
	active.classList.remove('active');
	return new Promise(r => {
		active.addEventListener('transitionend',r,{once:true})
		active.style.width = init;
		h.style.width = init;
	});
}

function moveTo(target){
	h.style.transform = `translateX(${u*target.dataset.idx}px)`
}

function expand(target){
	return new Promise(r => {
		target.addEventListener('transitionend',r,{once: true});
		const width = target.getElementsByClassName('inner')[0].getBoundingClientRect().width + 'px';
		target.style.width = width;
		h.style.width = width;
	})
}

setTimeout(()=>activate(outers[0]),500)

              
            
!
999px

Console