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 class="bb">
<div class="head"></div>
<div class="body"></div>
</div>
$body-width:30vmin;
$head-width:$body-width*.6;
$eye-width:$head-width*.2;
@mixin element($width,$height:$width,$radius:$width,$background:transparent) { // creates a element element and requires width, then sets the height and radius if you don't pass them (defaults to a circle)
background:$background;
border-radius:$radius;
content:"";
display:block;
height:$height;
width:$width;
}
* {
box-sizing:border-box;
position:relative;
}
body {
background:#222;
}
/* bb-8 */
.bb {
margin:20vmin auto 0;
top:25%;
}
/* antennae */
.head:after {
@include element(.5vmin,5vmin,$radius:0,$background:white);
border:0 solid black;
border-width:1vmin 0;
bottom:$head-width*.5;
box-shadow:-2vmin 4vmin 0 0 white;
left:55%;
position:absolute;
z-index:0;
}
/* head */
.head {
@include element($head-width,$head-width*.5,$head-width $head-width 0 0,white);
// animation:tilt 2s linear infinite;
background:
linear-gradient(transparent,transparent 8%,gray 8%,gray 22%,transparent 22%),
linear-gradient(transparent,transparent 30%,orange 30%,orange 40%,transparent 40%),
linear-gradient(90deg,transparent,transparent 30%,white 30%,white 70%,transparent 70%),
linear-gradient(90deg,transparent,transparent 8%,white 8%,white 12%,transparent 12%),
linear-gradient(90deg,transparent,transparent 3%,white 3%,white 5%,transparent 5%),
linear-gradient(90deg,transparent,transparent 24%,white 24%,white 26%,transparent 26%),
linear-gradient(90deg,transparent,transparent 74%,white 74%,white 80%,transparent 80%),
linear-gradient(90deg,transparent,transparent 88%,white 88%,white 90%,transparent 90%),
linear-gradient(90deg,transparent,transparent 94%,white 94%,white 96%,transparent 96%),
#fff linear-gradient(transparent,transparent 85%,orange 85%,orange 100%,transparent 100%);
box-shadow:
0 .5vmin 0 0 gray; // bottom of head
margin:0 auto 2vmin;
z-index:5;
}
/* eye */
.head:before {
@include element($eye-width,$eye-width,50%,white); // serves visually as the highlight of the eye, but properties help determine what other parts of the eye elements look like as well
box-shadow:
0 0 0 $eye-width*.2 white,
inset $eye-width*-.2 $eye-width*-.2 0 $eye-width*.4 black, // creates the look of the eye, but serves to create the highlight
// Secondary camera/eye.
$eye-width $eye-width*.8 0 $eye-width*-0.3 black,
$eye-width $eye-width*.8 0 $eye-width*-0.2 white,
$eye-width $eye-width*.8 0 $eye-width*-0.1 grey,
;
margin:auto;
position:inherit;
top:2vmin;
z-index:10;
}
/* body */
.body {
@include element($body-width,$body-width,50%);
// animation:roll 2s linear infinite;
background:
radial-gradient(circle at top,white,white 15%,transparent 15%),
radial-gradient(circle at bottom,white,white 15%,transparent 15%),
radial-gradient(circle at right,white,white 15%,transparent 15%),
radial-gradient(circle at left,white,white 15%,transparent 15%), // the white "panels" on the edges of the body
radial-gradient(circle at top,orange,orange 20%,transparent 20%),
radial-gradient(circle at bottom,orange,orange 20%,transparent 20%),
radial-gradient(circle at right,orange,orange 20%,transparent 20%),
radial-gradient(circle at left,orange,orange 20%,transparent 20%), /* the orange "borders" of the "panels" on the edges of the body, made by overlaying a white circle atop */
radial-gradient(white,white 20%,transparent 20%), /* center white panel on the body */
radial-gradient(orange,orange 30%,transparent 30%), /* center orange "borders" on the center panel on the body */
linear-gradient(90deg,transparent,transparent 50%,black 50%,black 50.5%,transparent 50.5%), /* vertical seam */
#fff linear-gradient(transparent,transparent 50%,black 50%,black 50.5%,transparent 50.5%) /* horizontal seam & body background */;
margin:0 auto;
}
@keyframes roll {
0% {
}
100% {
transform:rotate(180deg);
}
}
@keyframes tilt {
0% {
}
100% {
transform:
translateX(-40px)
rotate(-15deg)
;
}
}
Also see: Tab Triggers