css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!-- THE CHALLENGE: -->
<!-- 1. recreate version 3 (https://codepen.io/cjl750/pen/wdVxzV) with no javascript whatsoever
     2. make code as abstract as possible (e.g., trying to calc positions that would work with any number of dots instead of hard-coding the container width as we do in our media queries)
     3. highest browser support possible -->
<!-- Bonus points: turn v3's pseudo content into actual element content, so it's accessible to screen readers, search engines, etc. -->

<h1>Notable inventions, <span>1910–2000</span></h1>
<div class="flex-parent">
	<div class="input-flex-container">
		<input type="radio" name="timeline-dot" data-description="1910">
		<div class="dot-info" data-description="1910">
			<span class="year">1910</span>
			<span class="label">headset</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1920">
		<div class="dot-info" data-description="1920">
			<span class="year">1920</span>
			<span class="label">jungle gym</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1930" checked>
		<div class="dot-info" data-description="1930">
			<span class="year">1930</span>
			<span class="label">chocolate chip cookie</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1940">
		<div class="dot-info" data-description="1940">
			<span class="year">1940</span>
			<span class="label">Jeep</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1950">
		<div class="dot-info" data-description="1950">
			<span class="year">1950</span>
			<span class="label">leaf blower</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1960">
		<div class="dot-info" data-description="1960">
			<span class="year">1960</span>
			<span class="label">magnetic stripe card</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1970">
		<div class="dot-info" data-description="1970">
			<span class="year">1970</span>
			<span class="label">wireless LAN</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1980">
		<div class="dot-info" data-description="1980">
			<span class="year">1980</span>
			<span class="label">flash memory</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="1990">
		<div class="dot-info" data-description="1990">
			<span class="year">1990</span>
			<span class="label">World Wide Web</span>
		</div>
		<input type="radio" name="timeline-dot" data-description="2000">
		<div class="dot-info" data-description="2000">
			<span class="year">2000</span>
			<span class="label">Google AdWords</span>
		</div>
		<div id="timeline-descriptions-wrapper">
			<p data-description="1910">And future Call of Duty players would thank them.</p>
			<p data-description="1920">Because every kid should get to be Tarzan for a day.</p>
			<p data-description="1930">And the world rejoiced.</p>
			<p data-description="1940">Because building roads is inconvenient.</p>
			<p data-description="1950">Ain’t nobody got time to rake.</p>
			<p data-description="1960">Because paper currency is for noobs.</p>
			<p data-description="1970">Nobody likes cords. Nobody.</p>
			<p data-description="1980">Brighter than glow memory.</p>
			<p data-description="1990">To capitalize on an as-yet nascent market for cat photos.</p>
			<p data-description="2000">Because organic search rankings take work.</p>
		</div>
	</div>
</div>


<div style="position: absolute; bottom: 15px; right: 10px; font-size: 12px">
	<a href="https://codepen.io/cjl750/pen/wdVxzV" target="_blank">based off of version 3</a></div>
            
          
!
            
              $numDots: 20
$parentWidthBase: 0.8
$parentWidth: $parentWidthBase * 100vw
$parentMaxWidth: 1000px
$dotWidth: 25px
$active: #2C3E50
$inactive: #AEB6BF


html, body
	height: 100%
body
	font-family: 'Quicksand', sans-serif
	font-weight: 500
	color: #424949
	background-color: #ECF0F1
	padding: 0 25px
	display: flex
	flex-direction: column
	position: relative
h1
	text-align: center
	height: 38px
	margin: 60px 0
	span
		white-space: nowrap
.flex-parent
	display: flex
	flex-direction: column
	justify-content: center
	align-items: center
	width: 100%
	height: 100%
.input-flex-container
	display: flex
	justify-content: space-around
	align-items: center
	flex-wrap: wrap
	width: $parentWidth
	max-width: $parentMaxWidth
	position: relative
	z-index: 0
	margin-left: calc((#{$parentWidth} - #{$dotWidth}) / #{$numDots}) //make up for offset of .dot-info
input
	width: $dotWidth
	height: $dotWidth
	background-color: $active
	position: relative
	border-radius: 50%
	display: block
	-moz-appearance: none
	-webkit-appearance: none
	appearance: none
	cursor: pointer
	&:focus
		outline: none
	&::before, &::after
		content: ''
		display: block
		position: absolute
		z-index: -1
		top: 50%
		transform: translateY(-50%)
		background-color: $active
		width: $parentWidth / $numDots
		height: 5px
		max-width: $parentMaxWidth / $numDots
	&::before
		left: calc(#{-$parentWidth / $numDots} + #{$dotWidth / 2})
	&::after
		right: calc(#{-$parentWidth / $numDots} + #{$dotWidth / 2})
	&:checked
		background-color: $active
		&::before
			background-color: $active
		&::after
			background-color: $inactive
	&:checked
		~ input
			&, &::before, &::after
				background-color: $inactive
		+ .dot-info
			span
				font-size: 13px
				font-weight: bold	

.dot-info
	width: $dotWidth
	height: $dotWidth
	display: block
	// background-color: red
	visibility: hidden
	position: relative
	z-index: -1
	//position each span on top of the dot immediately before it; -1px at the end is just fudging the numbers for rounding error
	left: calc((((#{$parentWidth} - #{$dotWidth}) / #{$numDots}) * -1) - 1px)
	span
		visibility: visible
		position: absolute
		font-size: 12px
		&.year
			bottom: -30px
			left: 50%
			transform: translateX(-50%)
		&.label
			top: -65px
			left: 0
			transform: rotateZ(-45deg)
			width: 70px
			text-indent: -10px

#timeline-descriptions-wrapper
	width: 100%
	margin-top: 140px
	font-size: 22px
	font-weight: 400
	margin-left: calc((-#{$parentWidth} - #{$dotWidth}) / #{$numDots}) //make up for offset of .dot-info
	p
		margin-top: 0
		display: none


// magic shenanigans
$descriptions: '1910', '1920', '1930', '1940', '1950', '1960', '1970', '1980', '1990', '2000'

@each $desc in $descriptions
	input[data-description="#{$desc}"]:checked ~ #timeline-descriptions-wrapper
		p[data-description="#{$desc}"]
			display: block




@media (min-width: $parentMaxWidth / $parentWidthBase)
	.input-flex-container
		margin-left: #{($parentMaxWidth / $numDots) + ($dotWidth / 2)}
	input
		&::before
			left: #{-($parentMaxWidth / $numDots) + ($dotWidth / 2)}
		&::after
			right: #{-($parentMaxWidth / $numDots) + ($dotWidth / 2)}
	.dot-info
		left: calc((((#{$parentMaxWidth} - #{$dotWidth}) / #{$numDots}) * -1) - 1px)
	#timeline-descriptions-wrapper
		margin-left: #{-($parentMaxWidth / $numDots) + ($dotWidth / 2)}
	

@media (max-width: 630px)
	.flex-parent
		justify-content: initial
	.input-flex-container
		flex-wrap: wrap
		justify-content: center
		width: 400px
		height: auto
		margin-top: 15vh
		margin-left: 0
	input, .dot-info
		width: 60px
		height: 60px
		margin: 0 10px 50px
	input
		background-color: transparent !important
		z-index: 1
		&::before, &::after
			content: none
		&:checked
			+ .dot-info
				background-color: $active
				span
					&.year
						font-size: 14px
					&.label
						font-size: 12px
	.dot-info
		visibility: visible
		border-radius: 50%
		z-index: 0 // position behind input, so input remains clickable
		left: 0
		margin-left: -70px
		background-color: $inactive
		span
			&.year
				top: 0
				left: 0
				transform: none
				width: 100%
				height: 100%
				display: flex
				justify-content: center
				align-items: center
				color: #ECF0F1
			&.label
				top: calc(100% + 5px)
				left: 50%
				transform: translateX(-50%)
				text-indent: 0
				text-align: center
	#timeline-descriptions-wrapper
		margin-top: 30px
		margin-left: 0
		text-align: center

@media (max-width: 480px)
	.input-flex-container
		width: 340px

@media (max-width: 400px)
	.input-flex-container
		width: 300px
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console