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.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="164px" height="159px" viewBox="0 0 164 159" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.0.1 (7597) - http://www.bohemiancoding.com/sketch -->
<title>R</title>
<description>Created with Sketch.</description>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<path d="M45.600414,16.5896405 L49.024,0.184 L98.128,0.184 C102.736023,0.08799952 106.935981,0.49599544 110.728,1.408 C114.520019,2.32000456 117.759987,3.8559892 120.448,6.016 C123.136013,8.1760108 125.199993,10.9839827 126.64,14.44 C127.426331,16.3271954 127.997967,18.4433772 128.354911,20.7885659 L145.015549,18.974968 L160.189519,65.6756472 C161.704778,70.0284717 162.61461,74.1489468 162.91904,78.0371961 C163.22347,81.9254453 162.763867,85.481483 161.540217,88.7054157 C160.316566,91.9293485 158.283831,94.7600205 155.44195,97.1975168 C153.89011,98.5285379 152.054147,99.726132 149.934042,100.790309 L156.807296,116.075084 L117.081325,144.937691 C113.409784,147.723885 109.772133,149.862483 106.168262,151.353549 C102.564392,152.844614 99.0403735,153.506382 95.5961025,153.338871 C92.1518315,153.17136 88.8315526,152.11284 85.6351663,150.163278 C83.8897452,149.098699 82.1834216,147.722671 80.5161807,146.03518 L68.1034479,157.295288 L28.3774774,128.432681 C24.5930808,125.801819 21.4350574,123.00307 18.9033124,120.03635 C16.3715675,117.06963 14.6532078,113.922588 13.7481817,110.595127 C12.8431556,107.267667 12.8238457,103.782794 13.6902514,100.140402 C14.1633616,98.1514348 14.9447589,96.1034087 16.0344526,93.9963049 L1.48970761,85.6706594 L16.6636781,38.9699802 C17.9963337,34.5578241 19.6822192,30.6895043 21.7213854,27.3649049 C23.7605516,24.0403055 26.2225648,21.4335585 29.107499,19.5445859 C31.9924332,17.6556132 35.3007779,16.5603632 39.0326323,16.2588031 C41.0704516,16.0941329 43.2597053,16.2044111 45.600414,16.5896405 Z M92.7217432,67.5270064 C93.0477238,68.008449 93.3378089,68.5287797 93.592,69.088 C94.3120036,70.6720079 94.672,72.7119875 94.672,75.208 C94.672,77.2450479 94.6052967,79.2904157 94.4718888,81.3441248 C94.1147432,81.8029247 93.7095206,82.2396031 93.2562198,82.6541618 C91.9722321,83.8284113 90.1433412,84.8011765 87.7694923,85.5724868 C85.8321446,86.2019692 83.8662718,86.770584 81.8718531,87.2783366 C81.3251443,87.0804479 80.7846178,86.8299994 80.2502715,86.5269904 C78.7367198,85.6687085 77.2464067,84.229931 75.7792874,82.2106144 C74.5819407,80.5626081 73.4336678,78.8686635 72.3344571,77.1287628 C72.3537181,76.547661 72.424877,75.9561968 72.5479335,75.3543683 C72.8964949,73.6496715 73.8043216,71.7876928 75.2714409,69.7683762 C76.4687876,68.1203699 77.7249888,66.5048398 79.0400579,64.9217694 C79.5986706,64.7605174 80.1831757,64.645421 80.7935752,64.5764796 C82.5225496,64.3812008 84.5739305,64.6692122 86.9477795,65.4405225 C88.8851271,66.0700049 90.8097751,66.765497 92.7217432,67.5270064 Z" id="R" fill="#000000" sketch:type="MSShapeGroup"></path>
</g>
</svg>
<div id="circle"></div>
body{
background-color: #565656;
}
div{
border-radius: 50%;
width: 10px;
height: 10px;
background-color: pink;
border: 3px solid yellow;
position: absolute;
left: 0;
top: 0;
}
var bird = document.getElementById("R");
var circle = document.getElementById("circle");
var totalLength = bird.getTotalLength() >> 0;
var nowPos = 0;
setTimeout(function(){anim();},10);
function anim(){
if(nowPos > totalLength){
console.log("fin");
return;
}
var point = bird.getPointAtLength(nowPos);
circle.style.left = point.x + "px";
circle.style.top = point.y + "px";
nowPos++;
setTimeout(function(){anim();},10);
}
Also see: Tab Triggers