HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<section id="timeline">
<div class="section-wrapper">
<div id="timeline-slider-wrapper">
<div class="dot"></div>
<div data-labelbottom="2017" data-labeltop="Open store" class="year dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div data-labelbottom="2018" data-labeltop="Hire first staff" class="year dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div data-labelbottom="2019" data-labeltop="Expand product offerings" class="year dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div data-labelbottom="2020" data-labeltop="Open second store" class="year dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<input id="slider" type="range" min="1" max="17" value="2" />
</div>
</div>
</section>
<section id="description">
<div class="section-wrapper">
<h3>GOALS AND OBJECTIVES</h3>
<div>
<p>Year 2016, Quarter 4</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur, alias. Magni harum, earum fugit, officia eveniet minima, expedita accusantium, esse aspernatur omnis neque. Soluta, consequatur adipisci non molestiae omnis odit.</p>
</div>
<div class="text-default">
<p>Year 2017, Quarter 1</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae, consequuntur.</p>
</div>
<div>
<p>Year 2017, Quarter 2</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis assumenda ipsa maiores sunt fugiat deserunt pariatur est incidunt, enim quis.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus facere necessitatibus illum debitis minus amet recusandae optio fugit tempora veritatis.</p>
</div>
<div>
<p>Year 2017, Quarter 3</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Et, nihil. Ea nesciunt sed, quidem sapiente dolorem voluptatum, adipisci recusandae ducimus amet sequi atque ipsa officiis pariatur consectetur velit alias. Officiis, at illo aperiam ex accusamus, vel ab obcaecati doloribus numquam fugiat unde, error. Atque iusto nulla porro, ducimus ex vel.</p>
</div>
<div>
<p>Year 2017, Quarter 4</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero laudantium repudiandae quos magni iste cum, a quisquam eligendi quasi, at animi autem necessitatibus, cumque rem optio maiores. Placeat inventore repellat voluptate reprehenderit adipisci aperiam tempore?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio, aut illum repellat, itaque ducimus eius.</p>
</div>
<div>
<p>Year 2018, Quarter 1</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod, vel atque molestiae dolorum soluta magni, dolores a maxime iure illo.</p>
</div>
<div>
<p>Year 2018, Quarter 2</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt dicta non quam quae consectetur laborum eveniet, similique placeat illo velit enim eligendi facilis deleniti laboriosam iure natus totam! Nostrum ipsa debitis iste eum laborum odio, aliquam dolor fuga hic unde.</p>
</div>
<div>
<p>Year 2018, Quarter 3</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet, eveniet?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto officia, quam iste tempore eos, vel quis nulla, aliquid pariatur deleniti libero nesciunt dicta minus reiciendis.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex dolor, atque repellat nulla doloribus nostrum.</p>
</div>
<div>
<p>Year 2018, Quarter 4</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptates similique expedita cumque alias facilis commodi vitae recusandae, quisquam officia officiis autem distinctio quis consequuntur velit deleniti iusto illo accusantium earum, delectus blanditiis minima. Enim fugit totam, esse cumque consequatur dignissimos.</p>
</div>
<div>
<p>Year 2019, Quarter 1</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad, laboriosam!</p>
</div>
<div>
<p>Year 2019, Quarter 2</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed odio iste harum quia facilis, omnis autem non, corporis ullam perspiciatis earum voluptas facere accusantium itaque asperiores, illo debitis ducimus. Facere nobis ipsam beatae voluptatum nisi possimus aliquam eum excepturi, quisquam odit, alias dolores enim, soluta nulla. Ratione quam architecto dolore.</p>
</div>
<div>
<p>Year 2019, Quarter 3</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est consequuntur unde laborum officiis minus, impedit voluptates. Fugiat perspiciatis nesciunt itaque!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt doloribus eaque id in cumque aliquam voluptatem, officia unde assumenda corrupti!</p>
</div>
<div>
<p>Year 2019, Quarter 4</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae officia quas aut autem a quibusdam quam voluptas, optio iure recusandae eum, similique voluptate excepturi nobis suscipit, laboriosam laborum veniam mollitia!</p>
</div>
<div>
<p>Year 2020, Quarter 1</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus quod adipisci dolores, consectetur aperiam aliquam.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rerum ipsum vitae, consequuntur quidem, quasi quaerat.</p>
</div>
<div>
<p>Year 2020, Quarter 2</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem, perferendis facilis neque vero nostrum asperiores aperiam tenetur debitis sunt labore magnam ipsum nesciunt quo inventore explicabo hic at. Sed minus optio est illum, placeat, corporis necessitatibus fuga aperiam et officia, nobis nihil quas! Quasi temporibus corrupti consectetur, id natus nobis commodi quis. Inventore voluptate porro, excepturi dicta quasi consequuntur beatae.</p>
</div>
<div>
<p>Year 2020, Quarter 3</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, veritatis.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis ratione consequatur fugiat vero, dolor modi qui, libero rem repellat accusantium.</p>
</div>
<div>
<p>Year 2020, Quarter 4</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non quam aliquam aperiam consectetur sequi libero laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
</section>
<div style="background-color: #FBFCFC; width: 275px; height: 40px; padding: 10px; box-sizing: border-box; position: absolute; bottom: 5px; right: 5px; font-size: 0.9em;"><a href="https://codepen.io/cjl750/pen/XMyRoB" target="_blank">Alternate clickable, responsive version</a></div>
<div style="background-color: #FBFCFC; width: 275px; height: 55px; padding: 10px; box-sizing: border-box; position: absolute; bottom: 50px; right: 5px; font-size: 0.9em; line-height: 1.25"><a href="https://codepen.io/cjl750/pen/XMyRoB" target="_blank">Version 3: clickable, responsive, simplified code</a></div>
$zero: #FBFCFC
// $one: #FFC107
$two: #34495E
$three: #F1C40F
$four: #C0392B
html
background-color: $two
font-family: 'Raleway'
color: $zero
section
width: 100%
box-sizing: border-box
min-height: 33vh
.section-wrapper
padding: 10px
box-sizing: border-box
height: 100%
#timeline
padding-top: 50px
padding-bottom: 50px
background-color: $three
color: $two
#timeline-slider-wrapper
position: relative
top: 11vh
left: 5%
height: 3px
background-color: $zero
width: 90%
=circle
background-color: $zero
border-radius: 50%
float: left
position: relative
left: 5.3% // (line width / # of dots)
top: -6px
box-sizing: border-box
width: 14px
height: 14px
// MARGINS
// (((line width ÷ # of dots) ÷ 2) - (dot width ÷ 2))
// = (((0.9 ÷ 17) ÷ 2) - (14 ÷ 2))
// = (2.65% - 7px)
// 2.65% fudged slightly to 2.725% to make up for fact that range input thumb
// is not centered over beginning/end of line in initial and final position,
// but rather is left- or right-aligned
margin-right: calc(2.725% - 7px)
margin-left: calc(2.725% - 7px)
.dot
+circle
&:first-child
margin-left: calc(1.3625% - 7px)
&:nth-child(17)
margin-right: calc(1.3625% - 7px)
.year
&::before
content: attr(data-labeltop)
position: absolute
top: -75px
left: -15px
width: 140px
transform: rotateZ(-45deg)
display: block
font-size: 0.8em
font-weight: bold
&::after
content: attr(data-labelbottom)
position: absolute
top: 23px
left: -20px
padding: 10px
#slider
margin-top: 0
margin-bottom: 50px
width: 90%
position: relative
z-index: 1
top: -26px
left: 5%
#description
min-height: 30vh
background-color: $two
h3
color: $four
font-weight: 600
.section-wrapper > div
display: none
&.text-default
display: block
/* RANGE INPUT
* https://css-tricks.com/styling-cross-browser-
* compatible-range-inputs-css/
* /
// basic styles for cross-browser range input
input[type="range"]::-webkit-slider-thumb
-webkit-appearance: none
input[type="range"]
-webkit-appearance: none
background: transparent
width: 100%
input[type="range"]:focus
outline: none
input[type="range"]::-ms-track
width: 100%
cursor: pointer
background: transparent
border-color: transparent
color: transparent
// styles for our specific range input
// the circle you click and drag
=timeline-slider-thumb
height: 25px
width: 25px
border-radius: 50%
background: $two
border: 2px solid $zero
cursor: pointer
input[type="range"]::-webkit-slider-thumb
+timeline-slider-thumb
margin-top: -13px
input[type="range"]::-moz-range-thumb
+timeline-slider-thumb
input[type="range"]::-ms-thumb
+timeline-slider-thumb
// the track the circle sits on
=timeline-slider-track
width: 100%
cursor: pointer
height: 2px
background: $zero
input[type="range"]::-webkit-slider-runnable-track
+timeline-slider-track
input[type="range"]::-moz-range-track
+timeline-slider-track
input[type="range"]::-ms-track
+timeline-slider-track
$(function(){
$('#slider').on('change', function(){
var currentDesc = $('#description').find('.section-wrapper > div').filter(':visible');
var matchedDesc = $('#description').find('.section-wrapper > div').filter(':nth-child(' + (Number($('#slider').val()) + 1 ) + ')');
$(currentDesc).hide();
$(matchedDesc).fadeIn();
});
});
Also see: Tab Triggers