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.
<h1>Animated SVG - Rev Meter</h1>
<p><small>Animated with Velocity.js. Hover/tap me.</small></p>
<svg id="meter" onmouseenter="anim(this)" onclick="anim(this)" width="212px" height="212px" viewBox="0 0 212 212" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs></defs>
<g id="meter" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(6.000000, 6.000000)">
<g id="m3-3" transform="translate(31.373156, 128.088684) rotate(-112.500000) translate(-31.373156, -128.088684) translate(23.373156, 120.088684)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.67957356" cy="8.32975352" r="7.5"></circle>
</g>
<g id="m3-2" transform="translate(25.761049, 100.216901) rotate(-90.000000) translate(-25.761049, -100.216901) translate(17.761049, 92.216901)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="8.32971949" cy="8.32822699" r="7.5"></circle>
</g>
<g id="m3" transform="translate(31.488072, 71.067684) rotate(-67.500000) translate(-31.488072, -71.067684) translate(23.488072, 63.067684)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.67957356" cy="8.32975352" r="7.5"></circle>
</g>
<g id="m4" transform="translate(47.383658, 47.383658) rotate(-45.000000) translate(-47.383658, -47.383658) translate(39.466991, 39.466991)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="8.33333333" cy="8.33333333" r="7.5"></circle>
</g>
<g id="m5" transform="translate(72.321172, 30.877878) rotate(-22.500000) translate(-72.321172, -30.877878) translate(64.404505, 22.961211)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.67884317" cy="8.33047756" r="7.5"></circle>
</g>
<g id="m6" transform="translate(93.333333, 18.333333)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.5" cy="7.5" r="7.5"></circle>
</g>
<g id="m7" transform="translate(128.972642, 31.962703) rotate(22.500000) translate(-128.972642, -31.962703) translate(121.055976, 24.046036)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="8.14724978" cy="7.50444807" r="7.5"></circle>
</g>
<g id="m8" transform="translate(153.449675, 47.383658) rotate(45.000000) translate(-153.449675, -47.383658) translate(145.533009, 39.466991)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="8.33333333" cy="8.33333333" r="7.5"></circle>
</g>
<g id="m9" transform="translate(169.013053, 72.204529) rotate(67.500000) translate(-169.013053, -72.204529) translate(161.096386, 64.287862)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="8.14724978" cy="7.50444807" r="7.5"></circle>
</g>
<g id="m10" transform="translate(175.000000, 100.833333) rotate(90.000000) translate(-175.000000, -100.833333) translate(167.500000, 93.333333)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.5" cy="7.5" r="7.5"></circle>
</g>
<g id="m11" transform="translate(168.572110, 129.343321) rotate(135.000000) translate(-168.572110, -129.343321) translate(160.572110, 121.343321)" stroke-width="4" stroke="#979797">
<circle id="Oval-7" cx="7.89017059" cy="7.73828184" r="7.5"></circle>
</g>
<g id="dial" transform="translate(0.125006, 0.106735)">
<path d="M100.826446,112.396694 C107.216518,112.396694 112.396694,107.216518 112.396694,100.826446 C112.396694,94.4363748 107.216518,89.2561983 100.826446,89.2561983 C98.2449875,89.2561983 95.8609831,90.1016008 93.9361909,91.5306478 C91.0964057,93.6390242 89.2561983,97.0178335 89.2561983,100.826446 C89.2561983,107.216518 94.4363748,112.396694 100.826446,112.396694 Z" id="dial-center" stroke="#BE5340" stroke-width="8"></path>
<path d="M106.517943,68.6051788 C104.548204,68.2273321 102.51483,68.0295535 100.435458,68.0295535 C82.6378958,68.0295535 68.2101214,82.5184626 68.2101214,100.391438 C68.2101214,118.264413 82.6378958,132.753322 100.435458,132.753322 C118.233019,132.753322 132.660794,118.264413 132.660794,100.391438 C132.660794,98.6584505 132.525151,96.9572786 132.263946,95.2980449 L157.190427,43.9882887 L106.517947,68.6051796 Z" stroke="#E46954" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M99.8749941,199.066819 C154.647035,199.066819 199.048548,154.665307 199.048548,99.8932655 C199.048548,45.1212242 154.647035,0.719711764 99.8749941,0.719711764 C77.7482049,0.719711764 57.3138813,7.96601837 40.8156619,20.2149929 C16.4746459,38.2867908 0.701440376,67.2480134 0.701440376,99.8932655 C0.701440376,154.665307 45.1029528,199.066819 99.8749941,199.066819 Z" id="outer-2" stroke="#0A1D33"></path>
</g>
<path d="M100,200 C155.228475,200 200,155.228475 200,100 C200,44.771525 155.228475,0 100,0 C77.6888209,0 57.0842113,7.3066925 40.4485067,19.6577418 C15.9046489,37.8801381 0,67.0827041 0,100 C0,155.228475 44.771525,200 100,200 Z" id="outer" stroke="#0A1D33" stroke-width="11"></path>
</g>
</g>
</svg>
body {
background: #F0F4FB;
font-family: "Helvetica Neue", Helvetica, sans-serif;
text-align: center;
}
h1 {
font-weight: 200;
color: #222;
padding-bottom: 0;
margin-bottom: 0;
}
p {
margin-top: 10px;
}
/* I drafted it here on CodePen before putting it live on my site at http://gcgrafix.com/about
Not for IE.
Icon inspired by Wy Icons from UI8.net */
function anim(o) {
if (o.id == 'meter' && !o.isAnimating) {
// prevent anim queue build-up
o.isAnimating = true;
$('#dial').velocity({
//set the rotation center
//doesn't work for ie, coz ie.
transformOriginX: 201/2,
transformOriginY: 201/2
})
.velocity({
//turn it up
rotateZ: 60
},{
duration: 60
})
;
// the jitter
$('#dial').velocity({
rotateZ: '+=1deg'
},{
loop: 80,duration: 30,
easing: 'spring'
})
;
//and dial it back
$('#dial').velocity({
rotateZ: -10
}, {
complete: function () {
o.isAnimating = false;
}
})
;
}
}
Also see: Tab Triggers