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.
<svg viewBox="0 0 640 512" width="100" title="shoe-logo" id="logo" style="display:none">
<path d="M192 160h32V32h-32c-35.35 0-64 28.65-64 64s28.65 64 64 64zM0 416c0 35.35 28.65 64 64 64h32V352H64c-35.35 0-64 28.65-64 64zm337.46-128c-34.91 0-76.16 13.12-104.73 32-24.79 16.38-44.52 32-104.73 32v128l57.53 15.97c26.21 7.28 53.01 13.12 80.31 15.05 32.69 2.31 65.6.67 97.58-6.2C472.9 481.3 512 429.22 512 384c0-64-84.18-96-174.54-96zM491.42 7.19C459.44.32 426.53-1.33 393.84.99c-27.3 1.93-54.1 7.77-80.31 15.04L256 32v128c60.2 0 79.94 15.62 104.73 32 28.57 18.88 69.82 32 104.73 32C555.82 224 640 192 640 128c0-45.22-39.1-97.3-148.58-120.81z" />
</svg>
const assets = [{src:"https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600"}, "footbacking.jpg"];
const path = "https://assets.codepen.io/2104200/";
const frame = new Frame(FIT, 1024, 768, white, darker, assets, path);
frame.on("ready", ()=>{ // ES6 Arrow Function - similar to function(){}
zog("ready from ZIM Frame"); // logs in console (F12 - choose console)
// often need below - so consider it part of the template
const stage = frame.stage;
const stageW = frame.width;
const stageH = frame.height;
// REFERENCES for ZIM at https://zimjs.com
// see https://zimjs.com/intro.html for an intro example
// see https://zimjs.com/learn.html for video and code tutorials
// see https://zimjs.com/docs.html for documentation
// see https://codepen.io/topic/zim/ for ZIM on CodePen
// CODE HERE
// sometimes for blendmode to work the stage needs a shape on it
new Rectangle(stageW, stageH, white).addTo();
// make a container for the content and spin it slowly
const holder = new Container(stageW, stageH)
.centerReg()
.noMouse() // if nothing is interactve... noMouse() optimizes
.animate({
props:{rotation:360},
time:80,
loop:true,
ease:"linear" // imporant for constant rotation speed
});
// grab the logo SVG to add to Beads
const svg = zid("logo");
// make the path for the Beads - must be a Blob or Squiggle
// here we make a Blob from Circle
const path = new Blob({radius:300, points:new Circle(800)});
// if we have a remote SVG file then just load into Frame assets parameter and use asset(file.svg)
// but here we load from an SVG tag in the HTML
// this will provide a callback with the Bitmap as a parameter
svgToBitmap(svg, s=>{
// create Beads which place objects along the provided path
// centerReg these so we can invert their scale to make walking effect
const ring = new Beads({
path:path,
obj:s.sca(.6).centerReg(),
count:20,
visible:false // hide the path
}).center(holder);
// make the steps effect
// we did a variety of animation effects and eventually chose this one
// obj is the interval object and includes a count parameter
// we use this to cycle through the items
// the modulus % will start at the array beginning when equal to the count
// we swap scaleY in two places as we go
interval(.05, obj=>{
let step1 = ring.items[obj.count%ring.count];
let step2 = ring.items[(obj.count+ring.count/2)%ring.count];
step1.scaleY *= -1;
step2.scaleY *= -1;
});
// add some color to the feet
// by applying a lighten blend mode
// so far, underneath this picture is a white rectangle and black feet
// the lightest color will be kept so this is the white background
// and the color of the footbacking when it is on the black feet
// If we did not have the white background, the stage color is ignored
// so we would see the whole footbacking picture and not get the effect
asset("footbacking.jpg")
.center(holder)
.ble("lighten");
// make the rays - or just get an image and bring it in as an asset
const a = 360/ring.count;
// a Triangle() can have a 90 angle if -1 is provided to the third length parameter
// so if the adjacent side of the angle is 1000 then this is the opposite length
const op = Math.tan(a*RAD)*1000;
const rays = new Container().center(holder);
// we will just make a ray every other angle
loop(ring.count/2, i=>{
// come back half an angle so the ray is centered on the feet
// and spread the rays out at double the angle (for every other one)
// put the registration point of the ray at the left bottom corner
// so this gets put at 0,0 of the rays container
new Triangle(1000,op,-1).rot(-a/2+a*i*2).reg(0,op).alp(.05).addTo(rays);
});
// fade out the center by making a white circle that gradients to 0 alpha
// put this on the rays but under the logo text
new Circle(300,new RadialColor([white,white.toAlpha(0)],[0.5,1], 0,0,0, 0,0,300)).center(holder);
// animate in the logo text using the google font
// put a little spin on it and an elastic ease
new Label("LikeNuShus", 55, "Nunito")
.centerReg()
.sca(0)
.rot(-10)
.cache() // text animates better cached - but uncache after
.noMouse()
.animate({
props:{scale:1, rotation:0},
time:2.4,
ease:"elasticOut",
call:target=>{target.uncache();}
});
}); // end of svg processed
// DOCS FOR ITEMS USED
// https://zimjs.com/docs.html?item=Frame
// https://zimjs.com/docs.html?item=Container
// https://zimjs.com/docs.html?item=Circle
// https://zimjs.com/docs.html?item=Rectangle
// https://zimjs.com/docs.html?item=Triangle
// https://zimjs.com/docs.html?item=Blob
// https://zimjs.com/docs.html?item=Label
// https://zimjs.com/docs.html?item=noMouse
// https://zimjs.com/docs.html?item=animate
// https://zimjs.com/docs.html?item=loop
// https://zimjs.com/docs.html?item=alp
// https://zimjs.com/docs.html?item=ble
// https://zimjs.com/docs.html?item=rot
// https://zimjs.com/docs.html?item=reg
// https://zimjs.com/docs.html?item=sca
// https://zimjs.com/docs.html?item=addTo
// https://zimjs.com/docs.html?item=centerReg
// https://zimjs.com/docs.html?item=center
// https://zimjs.com/docs.html?item=Beads
// https://zimjs.com/docs.html?item=interval
// https://zimjs.com/docs.html?item=RadialColor
// https://zimjs.com/docs.html?item=toAlpha
// https://zimjs.com/docs.html?item=zog
// https://zimjs.com/docs.html?item=zid
// https://zimjs.com/docs.html?item=svgToBitmap
// FOOTER
// call remote script to make ZIM icon - you will not need this
createIcon();
createGreet();
}); // end of ready
Also see: Tab Triggers