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

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.

HTML

              
                <!-- THE CHALLENGE: -->
<!-- 1. recreate version 3 (https://codepen.io/cjl750/pen/mXbMyo) 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/mXbMyo" target="_blank">based off of version 3</a></div>
              
            
!

CSS

              
                $numDots: 20
$parentWidthBase: 0.8
$parentWidth: $parentWidthBase * 100vw
$parentMaxWidth: 1000px
$dotWidth: 25px
$active: #2C3E50
$inactive: #AEB6BF

html
	height: 100%
body
	min-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%
	min-height: 500px
.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
		padding-bottom: 30px
	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
              
            
!

JS

              
                
              
            
!
999px

Console