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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>An Animated Timeline</title>
<meta name="viewport" content="width=device-width">
</head>
<body>
<header>
<div class="poster">
<h1 class="poster__heading">The North Pole 2015
<span class="poster__subheading">The Ultimate Artic Adventure</span>
<a href="#" class="btn--primary">Book Request</a>
</div>
</div>
</header>
<main class="timeline-wrapper">
<div class="svg-timeline">
<svg width="8px" height="1490.7px" viewBox="0 0 8 1490.7">
<line id="timeline" fill="none" stroke="#FFFFFF" stroke-width="8" stroke-miterlimit="10" x1="4" y1="0" x2="4" y2="1490.7"/>
</svg>
</div>
<ol class="timeline clearfix">
<li class="timeline__item">
<h3 class="timeline__day">Day 1: <span>Helsinki, Finland</span></h3>
<p class="timeline__day-sum">Your adventure begins with a one-night stay in Helsinki, Finland's capital.</p>
<a href="#" class="btn--comments">19 Comments</a>
</li>
<li class="timeline__item right">
<h3 class="timeline__day dayTwo">Day 2: <span>Embarkation Day in Murmansk</span></h3>
<p class="timeline__day-sum">From Helsinki, your charter flight will take you to Murmansk, Russia, where you'll embark on your voyage to the North Pole and get acquainted with 50 Years of Victory, the world's largest and most powerful icebreaker.</p>
<a href="#" class="btn--comments">35 Comments</a>
</li>
<li class="timeline__item">
<h3 class="timeline__day dayThree">Day 3-6: <span>Northbound in the Arctic Ocean</span></h3>
<p class="timeline__day-sum">Watching the ship crush through the Arctic ice pack is a sight you'll never forget, made even more memorable by taking a helicopter flight for a thrilling aerial view of the ship and expansive Arctic Ocean.</p>
<p class="timeline__day-sum">You can expect days, and hours,to present variable sailing conditions this far north. The crossing from Murmansk to the North Pole can take us anywhere from 5-8 days. This means you'll have plenty of time to get to know your shipmates, stare out at the horizon, grab some drinks at the bar or do some laps in our indoor pool.</p>
<a href="#" class="btn--comments">72 Comments</a>
</li>
<li class="timeline__item right">
<h3 class="timeline__day dayFour">Day 7: <span>90° North</span></h3>
<p class="timeline__day-sum">All of the anticipation of the past few days reaches a climax as you reach the North Pole! Many travelers find themselves overcome with emotion, while others are in a festive mood. Take photos, wave a flag, enjoy your moment! Later, everyone enjoys a champagne toast and a BBQ on the ice. Add an exclamation to your success by rising high in one of our hot air balloons to commemerate this great moment.</p>
<a href="#" class="btn--comments">132 Comments</a>
</li>
<li class="timeline__item">
<h3 class="timeline__day dayFive">Day 8: <span>Southbound in the Arctic Ocean</span></h3>
<p class="timeline__day-sum">Now you can sit back and relax, everything from here on out is a bonus! Expect more great memories as you head south, you may get lucky and spot a Polar Bear hunting a Seal.</p>
<a href="#" class="btn--comments">2 Comments</a>
</li>
<li class="timeline__item right">
<h3 class="timeline__day daySix">Day 9-10: <span>Franz Josef Land</span></h3>
<p class="timeline__day-sum">Now you can sit back and relax, everything from here on out is a bonus! Expect more great memories as you head south, you may get lucky and spot a Polar Bear hunting a Seal.</p>
<a href="#" class="btn--comments">12 Comments</a>
</li>
</ol>
</main>
</body>
</html>
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.right {
float:right;
}
/* ====== MIXINS ===== */
// BEM selectors mixin
// block__element
@mixin e($element) {
&__#{$element} {
@content;
}
}
// block__element--modifier
@mixin m($modifier) {
&--#{$modifier}{
@content;
}
}
// Media queries mixin
$sm: 31.25em; // 500px
$md: 50em; // 800px
$lg: 75em; // 1200px
@mixin mq($break) {
@if $break=="sm" {
@media screen and ( min-width: $sm) {
@content;
}
}
@else if $break=="md" {
@media screen and ( min-width: $md) {
@content;
}
}
@else if $break=="lg" {
@media screen and ( min-width: $lg) {
@content;
}
}
@else {
@media screen and ( min-width: $break) {
@content;
}
}
}
// Variables
$font-family--primary: 'Open Sans';
$font-weight--light: 300;
$font-weight--norm: 400;
$font-weight--semi: 600;
$font-weight--bold: 700;
$font-weight--ultra: 900;
$orange: #FF9639;
// helpers
%center-text {
text-align: center;
}
%center-align {
margin: 0 auto;
}
html {
font-family: $font-family--primary;
font-size: 100%;
@include mq(sm) {
font-size: 105%;
}
@include mq(md) {
font-size: 115%;
}
@include mq(lg) {
font-size: 125%;
}
}
// button styles
%btn {
display: inline;
text-decoration: none;
padding: .45em 1.25em;
text-transform: uppercase;
font-weight: $font-weight--norm;
letter-spacing: 1px;
font-size: .75rem;
border-radius: 25px;
color: white;
font-family: $font-family--primary;
transition: all 250ms ease;
}
.btn--primary {
border: 1px solid white;
@extend %btn;
&:hover {
background-color: white;
color: black;
}
}
.poster {
height: 100vh;
width: 100%;
background-size: cover;
background-position: center center;
background-image: url("http://codepen.vincebrown.me/assets/images/snow-mountains.jpg");
// .poster__heading
@include e('heading') {
@extend %center-text;
@extend %center-align;
width: 95%;
color: white;
padding-top: 5.5rem;
font-weight: $font-weight--semi;
font-size: 2em;
transition: all 400ms ease;
@include mq(sm) {
font-size: 2.25em;
}
@include mq(md) {
font-size: 2.75em;
}
}
@include e('subheading') {
@extend %center-text;
display: block;
font-size: .3em;
letter-spacing: 5px;
font-weight: $font-weight--norm;
text-transform: uppercase;
color: $orange;
padding-top: .8em;
margin-bottom: .6em;
}
} // end .poster
// timeline
.btn--comments{
@extend %btn;
background-color: rgba(255,255,255,.4);
border:none;
font-size: .6em;
&:hover {
background-color: rgba(255,255,255,.6);
}
}
.timeline-wrapper{
position: relative;
padding-bottom:25em;
background: linear-gradient(#000 10%, #283048 60%, #55679a 70%, rgba(255,255,255,0));
&:after{
content:'';
display:block;
background-image: url('http://codepen.vincebrown.me/assets/images/white-mountains.jpg');
height:500px;
width: 100%;
background-size:cover;
position: absolute;
background-position:25% center;
z-index:-10;
bottom:0;
}
}
.svg-timeline {
position: absolute;
margin-left:50%;
transform: translateX(-50%);
display:none;
@include mq(md) {
display:block;
}
}
.timeline {
transition:all 250ms ease;
width: 90%;
margin: 0 auto;
@include mq(sm) {
width: 80%;
}
@include mq(md) {
width: 95%;
}
@include e('item') {
margin-bottom: 4em;
clear:both;
@include mq(md) {
width: 40%;
}
}
// .timeline__day
@include e('day') {
font-weight: $font-weight--semi;
font-size: .9em;
color:white;
text-transform: uppercase;
padding-bottom:.75em;
span{
font-weight: $font-weight--light;
color:orange;
text-transform: none;
}
}
//.timeline__day-sum
@include e('day-sum') {
color:white;
font-weight: $font-weight--light;
font-size: .8em;
display:block;
margin-bottom:1.5em;
line-height: 1.5;
}
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
/* start commented backslash hack \*/
* html .clearfix { height: 1%; }
.clearfix { display: block; }
/* close commented backslash hack */
var controller = new ScrollMagic.Controller();
TweenMax.set('#timeline',{visibility:0});
var tweenOne =
new TweenMax.fromTo('#timeline',1,{drawSVG:"0%"}, {drawSVG:"10%"});
var scene1 = new ScrollMagic.Scene({
triggerElement: '#timeline',
}).setTween(tweenOne).addTo(controller);
var tweenTwo =
new TweenMax.fromTo('#timeline',1,{drawSVG:"10%"}, {drawSVG:"20%"});
var scene2 = new ScrollMagic.Scene({
triggerElement: '.dayTwo',
}).setTween(tweenTwo).addTo(controller);
var tweenThree =
new TweenMax.fromTo('#timeline',1,{drawSVG:"20%"}, {drawSVG:"40%"});
var scene3 = new ScrollMagic.Scene({
triggerElement: '.dayThree',
}).setTween(tweenThree).addTo(controller);
var tweenFour =
new TweenMax.fromTo('#timeline',1,{drawSVG:"40%"}, {drawSVG:"65%"});
var scene3 = new ScrollMagic.Scene({
triggerElement: '.dayFour',
}).setTween(tweenFour).addTo(controller);
var tweenFive =
new TweenMax.fromTo('#timeline',1,{drawSVG:"65%"}, {drawSVG:"85%"});
var scene3 = new ScrollMagic.Scene({
triggerElement: '.dayFive',
}).setTween(tweenFive).addTo(controller);
var tweenSix =
new TweenMax.fromTo('#timeline',1,{drawSVG:"85%"}, {drawSVG:"102%"});
var scene3 = new ScrollMagic.Scene({
triggerElement: '.daySix',
}).setTween(tweenSix).addTo(controller);
Also see: Tab Triggers