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="wrapper">
<img class="world" src="https://svgsilh.com/svg/158348.svg"/>
<svg id="rocket" class="rocket" version="1.0" xmlns="http://www.w3.org/2000/svg"
width="140px" height="140px" viewBox="0 2 8060 12798"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.15, written by Peter Selinger 2001-2017
</metadata>
<g id="rocket"
fill="#000000" stroke="none">
<path d="M3889 12719 c-399 -261 -728 -609 -1179 -1249 -630 -894 -1106 -2009
-1294 -3030 -78 -427 -98 -643 -102 -1140 l-3 -415 -108 -88 c-59 -49 -216
-177 -348 -285 -422 -345 -548 -487 -684 -773 -152 -317 -206 -692 -147 -1014
16 -89 166 -769 341 -1540 134 -596 140 -612 264 -736 129 -128 283 -192 461
-192 195 0 313 60 560 284 63 57 167 149 230 204 63 55 216 190 340 300 192
171 359 315 421 363 14 10 26 4 80 -39 304 -243 678 -404 1052 -454 285 -37
589 -7 872 87 225 74 512 232 687 378 34 29 65 47 71 43 7 -4 262 -221 567
-483 706 -605 690 -592 760 -629 82 -44 141 -61 241 -68 235 -16 464 96 590
290 62 96 70 127 249 1027 257 1289 256 1284 247 1495 -16 334 -110 619 -297
899 -124 185 -223 277 -833 775 -103 84 -190 157 -193 162 -3 5 -5 156 -5 336
1 422 -21 700 -85 1088 -180 1083 -657 2221 -1332 3178 -388 550 -689 882
-1035 1138 -67 50 -250 169 -260 169 -2 0 -59 -37 -128 -81z"/>
<path d="M2730 2471 c-75 -24 -136 -75 -173 -145 l-22 -41 0 -650 0 -650 23
-47 c59 -119 221 -182 339 -133 21 9 106 84 208 186 l172 170 272 -540 c247
-490 275 -542 312 -570 102 -74 254 -63 343 25 17 17 138 249 293 558 l264
529 172 -171 c187 -185 214 -202 306 -201 104 1 191 53 234 140 l27 53 0 650
c0 727 3 692 -71 765 -53 53 -112 76 -194 75 -64 0 -80 -5 -185 -56 -196 -95
-391 -157 -625 -199 -188 -34 -541 -38 -741 -10 -257 37 -464 98 -689 204
-133 63 -203 78 -265 58z"/>
</g>
</svg>
</div>
.wrapper {
position:relative;
}
.world {
width: 540px;
position: absolute;
left: 0;
top: 0;
}
#rocket {
overflow:visible;
position:relative;
top:0;
left:0;
}
var earthSize = 540,
rocketSize = 140,
separation = 60, //how far off the edge of the globe the rocket will fly
earthCenter = earthSize / 2,
rocketCenter = rocketSize / 2;
//the rocket artwork is pointing down. We need it to start pointing up, so just rotate the group around its center.
TweenMax.set("#rocket g", {rotation:180, transformOrigin:"50% 50%"});
//position the rocket on the right edge of the earth.
TweenMax.set("#rocket", {
top:earthCenter - rocketCenter,
left:-rocketCenter - separation
});
//just rotate the rocket, and put the transform-origin in the center of the earth.
TweenMax.to("#rocket", 5, {
rotation:360,
transformOrigin:(earthCenter + rocketCenter + separation) + "px 50%",
ease:Linear.easeNone,
repeat:-1
}).progress(0.75); //since we want it to start at the bottom, we'll just jump to 75% through the animation.
TweenMax.to(".world", 10, {rotation:-360, ease:Linear.easeNone, repeat:-1})
Also see: Tab Triggers