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.info
%h2.title [[something]] evolution over time
%p.description
Dummy text. Scooby-Dooby-Doo zoinks jeepers jinkies monster ghost roast trap catch that villain danger from Daphne did it again bait plan let's split up and look for clues Scooby Snax spooky ice cream hot chocolate Mystery Machine.
%p.description Seriously now, just hover the damn data points
%ul.legend
-(1..3).each do |i|
%li.entry some description for the data series
%div.grid
-(1..3).each do |i|
%ul.f
-(1..7).each do |j|
%li.datapoint
%div.arrows
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Cabin+Condensed:400,500,600,700);
$n: 3; /* functions plotted */
$m: 7; /* data points for each */
$grid: (0 400) 100; /* limits & step array for values over years */
$years: (2005 2011) 1; /* limits & step array for years */
$cs: 5em; /* cell side */
$points: (65 150 280 285 265 175 50)
(30 95 195 340 410 290 140)
(125 120 120 200 290 375 430); /* values for each over years */
$nd: length($points); /* number of data sets */
$dd: .5em; /* dot diameter */
$bg: #fafafa; /* background-colour */
$fcs: #62b0c6 #435c61 #7b7c7e; /* colours for data set */
$discreet: #ececec; /* discreet highlighting colour */
$textc: #efe9e0; /* text colour */
$axesc: #008b8b; /* axes text colour */
$dc: #62b0c6; /* dot */
@function asin($val, $e: pi()/7200) {
/*
* $val: the value for which we compute the arc sine;
* $e: tolerated error; lower = better precision
*
* the function returns the arc sine of $val
*
* Examples:
* asin(.5) returns 29.97584deg (using default tolerated error)
* asin(0, pi()/180) returns 0deg
*/
$sum: 0; // the "infinite" sum we compute
$sign: 1; // sign of angle
$flag: 0; // 0 if angle in absolute value < 45deg, 1 otherwise
$i: 0; // current index
$c: 1;
$j: 2*$i + 1;
@if abs($val) > sin(45deg) {
$flag: 1;
$sign: $val/abs($val);
$val: sqrt(1 - pow($val, 2));
}
$term: $c*pow($val, $j)/$j;
@while abs($term) > $e {
$sum: $sum + $term;
$i: $i + 1;
$c: $c*(2*$i - 1)/(2*$i);
$j: 2*$i + 1;
$term: $c*pow($val, $j)/$j;
}
$result: $sign*($flag*pi()/2 + pow(-1, $flag)*$sum);
@return $result;
}
@function atan($val, $e: pi()/7200) {
/*
* $val: the value for which we compute the arc tangent
* $e: tolerated error; lower = better precision
*
* the function returns the arc tangent of $val
*
* Examples:
* atan(1) returns ~45deg (using default tolerated error)
* atan(0, pi()/180) returns 0deg
*/
$val: $val/sqrt(1 + pow($val, 2));
@return asin($val, $e);
}
html {
background: $bg;
font: 100% 'Cabin Condensed', sans-serif
}
body { font-size: .85em; }
ul { padding: 0; list-style: none; }
.info, .legend {
box-sizing: border-box;
float: left;
margin: .5em 1% 2em;
padding: .5em;
border: solid .2em $discreet;
}
.info { width: 65%; }
.title { margin: .25em 0 0; }
.legend {
width: 30%;
&:before {
display: block;
box-shadow: 0 1px $textc, 0 2px dimgrey;
text-transform: uppercase;
content: 'legend';
}
}
.entry {
margin: 1em 0 0;
background-size: 100% 100%;
transition: background-size 1s;
@for $i from 1 through $nd {
&:nth-child(#{$i}):before {
background: linear-gradient(90deg, nth($fcs, $i) 25%, transparent 25%) no-repeat;
background-size: inherit;
}
}
&:before {
display: block;
height: 1em;
content: '';
}
&:hover { background-size: 400% 100%; }
}
.grid {
clear: both;
position: relative;
margin: 0 auto;
border-left: solid 1px;
width: ($m + 2)*$cs; height: ($n + 2)*$cs;
background: linear-gradient(0deg, $textc 1px, transparent 1px);
background-size: 1px $cs, 100% 100%;
color: $textc;
&:before, &:after {
box-sizing: border-box;
position: absolute;
right: 100%; bottom: 0;
padding: $cs/2 .875em;
width: 3em;
color: $axesc;
font-weight: 700;
line-height: $cs;
text-align: right;
content: '';
}
&:before {
$dump: null;
$max: (nth(nth($grid, 1), 2) - nth(nth($grid, 1), 1))/nth($grid, 2);
height: ($n + 2)*$cs;
font-style: oblique;
@for $i from 0 through $max {
$dump: $dump (nth(nth($grid, 1), 2) - $i*nth($grid, 2));
content: '#{$dump}';
}
}
&:after {
$dump: null;
$max: (nth(nth($years, 1), 2) - nth(nth($years, 1), 1))/nth($years, 2);
height: ($m + 1)*$cs;
transform-origin: 100% 100%;
transform: rotate(90deg)
skewY(-36deg) scaleX(cos(30*pi()/180)) translateX(100%);
@for $i from 0 through $max {
$dump: $dump nth(nth($years, 1), 2) - nth($years, 2)*$i;
content: '#{$dump}';
}
}
}
.arrows {
$dump: unquote("inset 0 0 0") $dd/3 $discreet;
$max: (nth(nth($years, 1), 2) - nth(nth($years, 1), 1))/nth($years, 2);
position: absolute;
bottom: 0; left: 0;
margin: -$dd/2;
padding: 0;
width: $dd; height: $dd;
border-radius: 50%;
@for $i from 0 through $max {
$dump: $dump unquote(", ")
($i + 1)*$cs/2 0 0 (-$dd/3) $dc unquote(", ")
($i + 1)*$cs/2 0 $discreet;
}
box-shadow: $dump;
background: $dc;
font: 2em/1 sans-serif;
&:before, &:after {
position: absolute;
top: -50%; right: -50%; bottom: -50%; left: -50%;
color: $dc;
text-align: center;
content: '➲'
}
&:before {
transform: rotate(-90deg)
translate(($n + 2)*$cs/2 + $dd/2) scale(.9);
}
&:after {
transform:
translate(($m + 2)*$cs/2 + $dd/2) scale(.9);
}
}
.f {
position: absolute;
margin: 0;
width: 100%; height: 100%;
@for $i from 1 through $nd {
&:nth-of-type(#{$i}) {
.datapoint {
$max: (nth(nth($years, 1), 2) - nth(nth($years, 1), 1))/nth($years, 2) + 1;
@for $j from 1 through $max {
&:nth-child(#{$j}) {
bottom: nth(nth($points, $i), $j)*$cs/100;
left: $j*$cs;
&:before, &:after {
position: absolute;
right: 50%;
background: nth($fcs, $i);
}
&:before {
$c2: nth(nth($points, $i), $j);
@if $j > 1 {
$c3: nth(nth($points, $i), $j - 1);
$c2: $c2 - $c3;
}
$angle: (atan($c2/100)%(2*pi()))*180/pi();
top: 50%;
margin: -$dd/6;
width: $cs; height: $dd/3;
transform-origin: 100% 50%;
transform: skewY(#{-$angle}deg);
content: '';
}
&:after {
bottom: 100%;
margin: 2*$dd/3 -1.25em;
width: 2.5em; height: 1.5em;
border-radius: .25em;
transform: translateZ(-100em) scale(.01);
transform-origin: 50% 100%;
font-weight: 700;
line-height: 1.5;
text-align: center;
transition: transform .5s;
content: '#{nth(nth($points, $i), $j)}';
}
}
}
background: nth($fcs, $i);
&:hover {
box-shadow: 0 0 0 $dd/2 nth($fcs, $i),
0 -$dd/3 0 $dd/2 nth($fcs, $i),
0 -2*$dd/3 0 $dd/2 nth($fcs, $i);
}
}
}
}
}
.datapoint {
box-sizing: border-box;
position: absolute;
z-index: 1;
margin: -$dd;
border: solid 2*$dd/3 $discreet;
width: 2*$dd; height: 2*$dd;
border-radius: 50%;
cursor: pointer;
transition: box-shadow .5s;
}
.datapoint:hover { z-index: 2; }
.grid .f .datapoint:hover:after { transform: scale(1); }
Also see: Tab Triggers