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.
<canvas id="canvas" width="1000" height="700"></canvas>
<span class="link">Generated with <a href="https://jdan.github.io/isomer">isomer</a></span>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
display: flex;
flex-direction: column;
height: 100vh;
text-align: center;
}
#canvas {
margin: auto;
width: 500px;
height: 350px;
}
.link {
position: absolute;
bottom: 10px;
left: 10px;
}
/**
* An animated isometric structure
* by Jordan Scales
*
* Generated with Isomer
* https://jdan.github.com/isomer
*/
/* Create an Isomer instance with our canvas */
var iso = new Isomer(document.getElementById("canvas"));
/* Some convenient renames */
var Point = Isomer.Point;
var Path = Isomer.Path;
var Shape = Isomer.Shape;
var Color = Isomer.Color;
/* Rotation angle for our centerpiece */
var angle = 0;
function scene() {
/* Add some levels */
iso.add(Shape.Prism(new Point(1, 0, 0), 4, 4, 2));
iso.add(Shape.Prism(new Point(0, 0, 0), 1, 4, 1));
iso.add(Shape.Prism(new Point(-1, 1, 0), 1, 3, 1));
/* Some stair cases */
iso.add(Stairs(new Point(-1, 0, 0)));
/* Rotate this one */
iso.add(Stairs(new Point(0, 3, 1)).rotateZ(new Point(0.5, 3.5, 1), -Math.PI / 2));
/* Some more levels and stairs */
iso.add(Shape.Prism(new Point(3, 0, 2), 2, 4, 1));
iso.add(Shape.Prism(new Point(2, 1, 2), 1, 3, 1));
iso.add(Stairs(new Point(2, 0, 2)).rotateZ(new Point(2.5, 0.5, 0), -Math.PI / 2));
/* Add some colorful pyramids */
iso.add(Shape.Pyramid(new Point(2, 3, 3))
.scale(new Point(2, 4, 3), 0.5),
new Color(180, 180, 0));
iso.add(Shape.Pyramid(new Point(4, 3, 3))
.scale(new Point(5, 4, 3), 0.5),
new Color(180, 0, 180));
iso.add(Shape.Pyramid(new Point(4, 1, 3))
.scale(new Point(5, 1, 3), 0.5),
new Color(0, 180, 180));
iso.add(Shape.Pyramid(new Point(2, 1, 3))
.scale(new Point(2, 1, 3), 0.5),
new Color(40, 180, 40));
/* Add a knot with a short platform */
iso.add(Shape.Prism(new Point(3, 2, 3), 1, 1, 0.2), new Color(50, 50, 50));
/* Draw a spinning octahedron as our centerpiece */
iso.add(Octahedron(new Point(3, 2, 3.2))
.rotateZ(new Point(3.5, 2.5, 0), angle)
, new Color(0, 180, 180));
angle += Math.PI / 60;
requestAnimationFrame(scene);
}
requestAnimationFrame(scene);
/** Some Built-ins */
/* Draws some stars at a given point */
function Stairs(origin) {
var STEP_COUNT = 10;
/* Create a zig-zag */
var zigzag = new Path(origin);
var steps = [], i;
/* Shape to return */
var stairs = new Shape();
for (i = 0; i < STEP_COUNT; i++) {
/**
* 2
* __
* | 1
*/
var stepCorner = origin.translate(0, i / STEP_COUNT, (i + 1) / STEP_COUNT);
/* Draw two planes */
steps.push(new Path([
stepCorner,
stepCorner.translate(0, 0, -1 / STEP_COUNT),
stepCorner.translate(1, 0, -1 / STEP_COUNT),
stepCorner.translate(1, 0, 0)
]));
steps.push(new Path([
stepCorner,
stepCorner.translate(1, 0, 0),
stepCorner.translate(1, 1 / STEP_COUNT, 0),
stepCorner.translate(0, 1 / STEP_COUNT, 0)
]));
zigzag.push(stepCorner);
zigzag.push(stepCorner.translate(0, 1 / STEP_COUNT, 0));
}
zigzag.push(origin.translate(0, 1, 0));
for (i = 0; i < steps.length; i++) {
stairs.push(steps[i]);
}
stairs.push(zigzag);
stairs.push(zigzag.reverse().translate(1, 0, 0));
return stairs;
}
/**
* Draws an octohedron contained in a 1x1 cube location at origin
*/
function Octahedron(origin) {
/* Declare the center of the shape to make rotations easy */
var center = origin.translate(0.5, 0.5, 0.5);
var faces = [];
/* Draw the upper triangle /\ and rotate it */
var upperTriangle = new Path([
origin.translate(0, 0, 0.5),
origin.translate(0.5, 0.5, 1),
origin.translate(0, 1, 0.5)
]);
var lowerTriangle = new Path([
origin.translate(0, 0, 0.5),
origin.translate(0, 1, 0.5),
origin.translate(0.5, 0.5, 0)
]);
for (var i = 0; i < 4; i++) {
faces.push(upperTriangle.rotateZ(center, i * Math.PI / 2));
faces.push(lowerTriangle.rotateZ(center, i * Math.PI / 2));
}
/* We need to scale the shape along the x & y directions to make the
* sides equilateral triangles */
return new Shape(faces).scale(center, Math.sqrt(2)/2, Math.sqrt(2)/2, 1);
}
/* Draws an impossible MC Escher style knot */
function Knot(origin) {
var knot = new Shape();
knot.paths = knot.paths.concat(Shape.Prism(Point.ORIGIN, 5, 1, 1).paths);
knot.paths = knot.paths.concat(Shape.Prism(new Point(4, 1, 0), 1, 4, 1).paths);
knot.paths = knot.paths.concat(Shape.Prism(new Point(4, 4, -2), 1, 1, 3).paths);
knot.push(new Path([
new Point(0, 0, 2),
new Point(0, 0, 1),
new Point(1, 0, 1),
new Point(1, 0, 2)
]));
knot.push(new Path([
new Point(0, 0, 2),
new Point(0, 1, 2),
new Point(0, 1, 1),
new Point(0, 0, 1)
]));
return knot.scale(Point.ORIGIN, 1/5).translate(-0.1, 0.15, 0.4).translate(origin.x, origin.y, origin.z);
}
Also see: Tab Triggers