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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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="earth"></div>
:root {
--stars: 5vw 15vh 2px white, 1vw 33vh 0px white, 2vw 25vh 2px white, 10vw 10vh 2px white, 12vw 20vh 0px white, 30vw 15vh 2px white, 16vw 5vh 2px white, 24vw 10vh 0px white, 32vw 40vh 0px white, 33vw 35vh 2px white, 12vw 38vh 2px white, 24vw 10vh 0px white, 33vw 5vh 2px white, 20vw 10vh 0px white, 80vw 10vh 2px white, 62vw 20vh 0px white, 60vw 15vh 2px white, 70vw 7vh 0px white, 62vw 50vh 0px white, 65vw 35vh 2px white, 64vw 10vh 0px white, 85vw 2vh 0px white, 92vw 40vh 0px white, 75vw 35vh 2px white, 90vw 10vh 0px white, 80vw 33vh 2px white, 80vw 10vh 0px white, 95vw 2vh 2px white, 95vw 25vh 0px white, 65vw 25vh 0px white, 85vw 20vh 0px white, 75vw 17vh 0px white, 25vw 25vh 0px white,95vw 95vh 2px white, 1vw 90vh 0px white, 2vw 80vh 2px white, 10vw 70vh 2px white, 12vw 65vh 0px white, 30vw 80vh 2px white, 16vw 85vh 2px white, 14vw 50vh 0px white, 5vw 55vh 0px white, 20vw 58vh 2px white, 80vw 38vh 2px white, 90vw 90vh 0px white, 90vw 95vh 2px white, 88vw 10vh 0px white, 80vw 10vh 2px white, 62vw 20vh 0px white, 60vw 15vh 2px white, 70vw 7vh 0px white, 62vw 50vh 0px white, 65vw 35vh 2px white, 64vw 10vh 0px white, 85vw 55vh 0px white, 92vw 60vh 0px white, 75vw 67vh 2px white, 60vw 80vh 0px white, 56vw 95vh 2px white, 75vw 70vh 0px white, 70vw 96vh 2px white, 79vw 87vh 0px white, 80vw 78vh 0px white, 85vw 70vh 0px white, 90vw 80vh 0px white, 25vw 25vh 0px white;
}
html, body {
height: 100vh;
}
body {
background: #060817;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
body:before {
content: ' ';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 50%;
border-radius: 100%;
width: 3px;
height: 4px;
z-index: -1;
opacity: 0.3;
box-shadow: var(--stars);
}
.earth {
perspective: 400vmin;
transform-style: preserve-3d;
width: min(80vmin, 320px);
height: min(80vmin, 320px);
}
.earth::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0%;
background: url(https://pbs.twimg.com/media/DON8Y_eUMAAV4pi.jpg) repeat-x;
background-size: cover;
border-radius: 50%;
animation: rotate 30s infinite linear;
box-shadow: -80px -15px 80px 10px rgba(0,0,0,.9) inset, -10px 0px 15px -7px #f0df1759;
}
@keyframes rotate {
0% {
background-position: 0px 0px;
}
100% {
background-position:1200px 0px;
}
}
Also see: Tab Triggers