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.
<div id="main">
<svg id="mobiltelefonens" width="100px" height="300px" viewBox="0 0 100 300">
<g id="a" style="display: none;">
<path g d="M 26 70C 26 70 59 70 59 70 59 70 64 45 64 45 64 45 64 6 64 6 64 6 69 6 69 6 69 6 69 45 69 45 69 45 73 70 73 70 73 70 76 70.75 76 74 76 75.75 76 125.33 76 125.33 76 125.33 76 153.83 76 153.83 76 153.83 76 290 76 290 76 290 75.5 294 73 294 72.25 294 26 294 26 294 23.37 294 23 290 23 290 23 290 23 154.17 23 154.17 23 154.17 23 125.5 23 125.5 23 125.5 23 74 23 74 23 70.75 26 70 26 70Z" fill="rgb(45,44,46)"/>
<rect x="28" y="125" width="42" height="29" fill="rgb(255,255,255)"/>
</g>
<g id="b" style="display: none;">
<path g d="M 48.5 134.5C 67.33 134.33 73 136 73 136 73 136 73 111 73 111 73 111 73 82 73 82 73 82 79 82 79 82 79 82 79 111 79 111 79 111 79 135 79 135 79 135 79 139 79 139 79 139 79 164 79 164 79 164 79 208.67 79 208.67 79 208.67 79 290 79 290 79 290 78.12 293.87 75 294 73.25 294 24 294 24 294 21.13 294 20 290 20 290 20 290 20 208.5 20 208.5 20 208.5 20 163.83 20 163.83 20 163.83 20 139 20 139 20 139 30.67 134.5 48.5 134.5Z" fill="rgb(45,44,46)"/>
<rect x="25" y="164" width="47" height="44" fill="rgb(255,255,255)"/>
</g>
<g id="c" style="display: none;" data-easing="quart-in-out" data-duration="500">
<path g d="M 34 159C 36.94 158 45 157 45 157 45 157 49 157 49 157 49 157 50 157 50 157 50 157 51 157 51 157 51 157 55 157 55 157 55 157 62.44 157.88 65 159 65.87 159.44 69.75 160.56 72 165 75.63 172.63 76.88 176.38 77 197.17 77.38 220.75 73 233.33 73 233.33 73 233.33 73 290 73 290 73.06 293.62 70 294 70 294 70 294 30 294 30 294 27.44 294 27 290 27 290 27 290 27 232.83 27 232.83 27 232.83 23 218.12 23 197.17 23.12 175.63 25.63 170.88 28 165 30.5 160.37 34 159 34 159Z" fill="rgb(45,44,46)"/>
<rect x="31" y="194" width="37" height="26" fill="rgb(255,255,255)"/>
</g>
<g id="d" style="display: none;">
<path g d="M 33 172C 36.33 170 40 170 40 170 40 170 46 170 46 170 46 170 50 170 50 170 50 170 53 170 53 170 53 170 60 170 60 170 60 170 64.06 170.09 67 172 68.97 173.72 69.83 174.5 72 181 74.67 189.83 74 197.33 74 197.33 74 197.33 74 225.83 74 225.83 74 225.83 74 290 74 290 74.06 293.12 71 294 71 294 71 294 29 294 29 294 26.44 293.94 26 290 26 290 26 290 26 226.17 26 226.17 26 226.17 26 197.5 26 197.5 26 197.5 26.17 188.17 28 182 29.67 175.67 30.97 173.47 33 172Z" fill="rgb(45,44,46)"/>
<rect x="31" y="196" width="37" height="25" fill="rgb(255,255,255)"/>
</g>
<g id="e" style="display: none;">
<path g d="M 32 165C 32 165 43 165 43 165 43 165 43 178 43 178 43 178 43 182 43 182 43 182 43 186 43 186 43 186 43 193 43 193 43 193 46.63 191.94 55 192 65 192 74 196 74 196 74 196 74 216.33 74 216.33 74 216.33 74 244.83 74 244.83 74 244.83 74 277 74 277 74.12 289 71 294 71 294 71 294 29 294 29 294 29 294 26 287.88 26 277 26 276.22 26 245.17 26 245.17 26 245.17 26 216.5 26 216.5 26 216.5 26 196 26 196 26 196 32 165 32 165Z" fill="rgb(45,44,46)"/>
<rect x="31" y="206" width="37" height="25" fill="rgb(255,255,255)"/>
</g>
<g id="f" style="display: none;" data-easing="quart-in-out" data-duration="500">
<path g d="M 31.16 192.73C 31.16 192.73 31.22 192.67 31.22 192.67 31.22 192.67 31.31 192.61 31.31 192.61 31.31 192.61 39.48 190 48.94 190 60.08 189.98 68.62 192.59 68.62 192.59 68.62 192.59 68.69 192.67 68.69 192.67 68.69 192.67 68.77 192.8 68.77 192.8 68.77 192.8 68.8 192.92 68.8 192.92 68.8 192.92 68.83 193 68.83 193 68.83 193 72 232.06 72 240.83 72 276 69 292 69 292 69 292 63.38 294.94 51 295 49.12 295.25 48 295 48 295 35.5 295 30 292 30 292 30 292 27 275.81 27 241.17 27 231.94 31.03 192.94 31.03 192.94 31.03 192.94 31.08 192.83 31.08 192.83 31.08 192.83 31.16 192.73 31.16 192.73Z" fill="rgb(45,44,46)"/>
<rect x="33" y="212" width="33" height="23" fill="rgb(255,255,255)"/>
</g>
<g id="g" style="display: none;">
<path g d="M 28 189C 28 189 35 189 35 189 35 189 42 189 42 189 42 189 49 189 49 189 49 189 56 189 56 189 56 189 64 189 64 189 64 189 72 189 72 189 74.81 190.44 75 193 75 193 75 193 75 244.33 75 244.33 75 244.33 75 272.83 75 272.83 75 272.83 75 290 75 290 73.94 293.31 72 294 72 294 72 294 28 294 28 294 25.69 293.06 25 290 25 290 25 290 25 273.17 25 273.17 25 273.17 25 244.5 25 244.5 25 244.5 25 193 25 193 25.63 190.13 28 189 28 189Z" fill="rgb(45,44,46)"/>
<rect x="30" y="203" width="40" height="52" fill="rgb(255,255,255)"/>
</g>
<g id="h" style="display: none;">
<path g d="M 21 170C 21 170 28 170 28 170 28 170 35 170 35 170 35 170 42 170 42 170 42 170 49 170 49 170 49 170 57 170 57 170 57 170 79 170 79 170 81.81 171.44 82 174 82 174 82 174 82 244.33 82 244.33 82 244.33 82 272.83 82 272.83 82 272.83 82 290 82 290 80.94 293.31 79 294 79 294 79 294 21 294 21 294 18.69 293.06 18 290 18 290 18 290 18 273.17 18 273.17 18 273.17 18 244.5 18 244.5 18 244.5 18 174 18 174 18.62 171.13 21 170 21 170Z" fill="rgb(45,44,46)"/>
<rect x="23" y="190" width="54" height="83" fill="rgb(255,255,255)"/>
</g>
<g id="i" style="display: none;">
<path g d="M 18 158C 18 158 25 158 25 158 25 158 32 158 32 158 32 158 39 158 39 158 39 158 46 158 46 158 46 158 54 158 54 158 54 158 82 158 82 158 84.81 159.44 85 162 85 162 85 162 85 244.33 85 244.33 85 244.33 85 272.83 85 272.83 85 272.83 85 290 85 290 83.94 293.31 82 294 82 294 82 294 18 294 18 294 15.69 293.06 15 290 15 290 15 290 15 273.17 15 273.17 15 273.17 15 244.5 15 244.5 15 244.5 15 162 15 162 15.63 159.13 18 158 18 158Z" fill="rgb(45,44,46)"/>
<rect x="20" y="175" width="60" height="100" fill="rgb(255,255,255)"/>
</g>
<g id="j" style="display: none;">
<path g d="M 18 149C 18 149 25 149 25 149 25 149 32 149 32 149 32 149 39 149 39 149 39 149 46 149 46 149 46 149 54 149 54 149 54 149 82 149 82 149 84.81 150.44 85 153 85 153 85 153 85 244.33 85 244.33 85 244.33 85 272.83 85 272.83 85 272.83 85 290 85 290 83.94 293.31 82 294 82 294 82 294 18 294 18 294 15.69 293.06 15 290 15 290 15 290 15 273.17 15 273.17 15 273.17 15 244.5 15 244.5 15 244.5 15 153 15 153 15.63 150.13 18 149 18 149Z" fill="rgb(45,44,46)"/>
<rect x="20" y="161" width="60" height="120" fill="rgb(255,255,255)"/>
</g>
<g id="k" style="display: none;">
<path g d="M 6 109C 6 109 61 109 61 109 61 109 68 109 68 109 68 109 75 109 75 109 75 109 82 109 82 109 82 109 90 109 90 109 90 109 93 109 93 109 95.81 110.44 96 113 96 113 96 113 96 244.33 96 244.33 96 244.33 96 272.83 96 272.83 96 272.83 96 290 96 290 94.94 293.31 93 294 93 294 93 294 6 294 6 294 3.69 293.06 3 290 3 290 3 290 3 273.17 3 273.17 3 273.17 3 244.5 3 244.5 3 244.5 3 113 3 113 3.62 110.12 6 109 6 109Z" fill="rgb(45,44,46)"/>
<rect x="8" y="126" width="83" height="147" fill="rgb(255,255,255)"/>
</g>
</svg>
<div class="timeline">
<ul class="timeline-list">
<li class="timeline-item -date">
<span>1990</span>
</li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item -date">
<span>1995</span>
</li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item -date">
<span>2000</span>
</li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item -date">
<span>2005</span>
</li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item -date">
<span>2010</span>
</li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item"></li>
<li class="timeline-item -date">
<span>2015</span>
</li>
</ul>
</div>
</div>
<a class="c" href="https://twitter.com/pixelia_me" target="_blank">@pixelia_me</a>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700);
$bgcolor: rgb(76,202,220);
$maincolor: rgb(45,44,46);
html {font-size: 16px}
html, body {
height: 100%;
min-height: 415px;
}
body {
background-color: $bgcolor;
font-size: 13px;
}
#main {
position: absolute;
width: 300px;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
}
/* timeline */
.timeline {
overflow: hidden;
position: relative;
margin-top: 2.25em;
padding-left: 100px;
&:before,
&:after {
content: '';
width: 75px;
position: absolute;
top: 0;
height: 96px;
z-index: 1;
}
&:before {
left: 0;
background-image: linear-gradient(to right, $bgcolor, rgba($bgcolor,0));
}
&:after {
right: 0;
background-image: linear-gradient(to right, rgba($bgcolor,0), $bgcolor);
}
}
/* timeline ul */
.timeline-list {
margin: 0;
padding: 0;
white-space: nowrap;
list-style: none;
transition: transform 600ms cubic-bezier(0.680, -0.550, 0.265, 1.550);
}
.timeline-item {
display: inline-block;
vertical-align: top;
width: 24px;
&:before {
content: '';
display: block;
margin: 0 auto;
width: 2px;
height: 8px;
background: $maincolor;
}
&.-date {
width: 36px;
span {
font-family: 'Roboto', sans-serif;
display: block;
margin: 2em 0;
font-weight: 700;
}
&:before {
width: 4px;
height: 14px;
}
}
}
.c {
position: fixed;
bottom: 0;
right: 0;
display: inline-block;
font-size: .7rem;
padding: 1.5em 2em;
font-family: Monaco, monospace;
color: darken($bgcolor, 34);
}
/* Noel Delgado | @pixelia_me */
/*
*** full attribution ***
- Original infographic
- http://www.fremtidensbusiness.dk/wp-content/uploads/2015/04/evolution.png
*/
var CONFIG = {
duration: 1000,
easing: 'elastic-out',
rotation: 'none',
};
var phonesInfo = [].slice.call(document.getElementsByTagName('g'), 0).map(function(el) {
return {
id : el.getAttribute('id'),
easing : el.getAttribute('data-easing') || CONFIG.easing,
duration : el.getAttribute('data-duration') || CONFIG.duration
};
});
var phonesLen = (phonesInfo.length - 1);
var timelineElement = document.querySelector('.timeline-list');
var moveTimelinePxs = 69;
var now, delta;
var interval = 1500 * 1;
var then = +new Date();
var index = 0;
var M = new SVGMorpheus('#mobiltelefonens', CONFIG);
/* ~~~~~~~ */
update();
loop();
function update() {
var p = phonesInfo[index++];
var x = (((index - 1) * moveTimelinePxs) * -1);
M.to(p.id, {
easing: p.easing,
duration: p.duration
});
timelineElement.style.webkitTransform = 'translateX(' + x + 'px)';
timelineElement.style.transform = 'translateX(' + x + 'px)';
if (index > phonesLen) index = 0;
p = x = null;
}
function loop() {
requestAnimationFrame(loop);
now = +new Date();
delta = now - then;
if (delta > interval) {
then = now - (delta % interval);
update();
}
}
Also see: Tab Triggers