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.
<svg class="stopwatch" viewBox="0 0 155 208" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M9.4,14.6666667 L28.8333333,14.6666667 C29.9379028,14.6666667 30.8333333,15.5620972 30.8333333,16.6666667 L30.8333333,31 C30.8333333,32.1045695 29.9379028,33 28.8333333,33 L9.4,33 C8.2954305,33 7.4,32.1045695 7.4,31 L7.4,16.6666667 C7.4,15.5620972 8.2954305,14.6666667 9.4,14.6666667 Z" id="path-1"></path>
<filter x="-19.2%" y="-24.5%" width="138.4%" height="149.1%" filterUnits="objectBoundingBox" id="filter-2">
<feOffset dx="-6" dy="-9" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<rect id="path-3" x="0" y="0" width="37" height="18.3333333" rx="2"></rect>
<filter x="-12.2%" y="-24.5%" width="124.3%" height="149.1%" filterUnits="objectBoundingBox" id="filter-4">
<feOffset dx="-6" dy="-9" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<path d="M9.42325581,2.12560386 L28.9302326,2.12560386 C30.0348021,2.12560386 30.9302326,3.02103437 30.9302326,4.12560386 L30.9302326,18 C30.9302326,19.1045695 30.0348021,20 28.9302326,20 L9.42325581,20 C8.31868631,20 7.42325581,19.1045695 7.42325581,18 L7.42325581,4.12560386 C7.42325581,3.02103437 8.31868631,2.12560386 9.42325581,2.12560386 Z" id="path-5"></path>
<filter x="-19.1%" y="-25.2%" width="138.3%" height="150.4%" filterUnits="objectBoundingBox" id="filter-6">
<feOffset dx="-6" dy="-9" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 0 0.811764706 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<path d="M6.39576918,0.747236094 L31.5120482,0.747236094 C34.8257567,0.747236094 37.5120482,3.4335276 37.5120482,6.74723609 L37.5120482,12.6216322 C37.5120482,15.9353407 34.8257567,18.6216322 31.5120482,18.6216322 L6.39576918,18.6216322 C3.08206068,18.6216322 0.39576918,15.9353407 0.39576918,12.6216322 L0.39576918,6.74723609 C0.39576918,3.4335276 3.08206068,0.747236094 6.39576918,0.747236094 Z" id="path-7"></path>
<filter x="-12.1%" y="-25.2%" width="124.2%" height="150.4%" filterUnits="objectBoundingBox" id="filter-8">
<feOffset dx="-6" dy="-9" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.810400723 0 0 0 0 0.200090062 0 0 0 0 0.274595959 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<ellipse id="path-9" cx="75.5" cy="76" rx="75.5" ry="76"></ellipse>
/ Blue circle shadow
<filter x="-9.6%" y="-9.5%" width="119.2%" height="119.1%" filterUnits="objectBoundingBox" id="filter-10">
<feOffset dx="-26" dy="-26" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.192156863 0 0 0 0 0.525490196 0 0 0 0 0.737254902 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<ellipse id="path-11" cx="75.9389535" cy="76.4418605" rx="63.6482558" ry="64.0697674"></ellipse>
<filter x="-3.9%" y="-3.9%" width="107.9%" height="107.8%" filterUnits="objectBoundingBox" id="filter-12">
<feOffset dx="-7" dy="-7" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.855521896 0 0 0 0 0.855521896 0 0 0 0 0.855521896 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<path d="M68.5721689,82.9737108 L110.707425,40.5594133" id="path-13"></path>
<filter x="-9.0%" y="-7.4%" width="116.4%" height="116.3%" filterUnits="objectBoundingBox" id="filter-14">
<feOffset dx="-5" dy="-5" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.192156863 0 0 0 0 0.525490196 0 0 0 0 0.737254902 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
<ellipse id="path-15" cx="75.9389535" cy="76.4418605" rx="4.82848837" ry="4.86046512"></ellipse>
<filter x="-36.2%" y="-36.0%" width="172.5%" height="172.0%" filterUnits="objectBoundingBox" id="filter-16">
<feOffset dx="-4" dy="-4" in="SourceAlpha" result="shadowOffsetInner1"></feOffset>
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
<feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 0.192156863 0 0 0 0 0.525490196 0 0 0 0 0.737254902 0 0 0 1 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
</filter>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Group-10-Copy-3" transform="translate(2.000000, 2.000000)" fill-rule="nonzero">
<path d="M76.5,55 C61.3121694,55 49,42.6878306 49,27.5 C49,12.3121694 61.3121694,0 76.5,0 C91.6878306,0 104,12.3121694 104,27.5 C104,42.6878306 91.6878306,55 76.5,55 Z M76.5,48 C87.8218374,48 97,38.8218374 97,27.5 C97,16.1781626 87.8218374,7 76.5,7 C65.1781626,7 56,16.1781626 56,27.5 C56,38.8218374 65.1781626,48 76.5,48 Z" id="Combined-Shape" stroke="#124458" stroke-width="3" fill="#D8D8D8" stroke-linecap="round" stroke-linejoin="round"></path>
<g id="Group-8" transform="translate(57.000000, 28.000000)">
<g id="Group-6">
<g id="Rectangle-9">
<use fill="#E8E8E8" xlink:href="#path-1"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"></use>
<path stroke="#124458" stroke-width="3" d="M9.4,16.1666667 C9.12385763,16.1666667 8.9,16.3905243 8.9,16.6666667 L8.9,31 C8.9,31.2761424 9.12385763,31.5 9.4,31.5 L28.8333333,31.5 C29.1094757,31.5 29.3333333,31.2761424 29.3333333,31 L29.3333333,16.6666667 C29.3333333,16.3905243 29.1094757,16.1666667 28.8333333,16.1666667 L9.4,16.1666667 Z" stroke-linejoin="square"></path>
</g>
<g id="Rectangle-9-Copy">
<use fill="#E8E8E8" xlink:href="#path-3"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-3"></use>
<rect stroke="#124458" stroke-width="3" stroke-linejoin="square" x="1.5" y="1.5" width="34" height="15.3333333" rx="2"></rect>
</g>
</g>
<g id="Group-7" transform="translate(6.166667, 1.783784)" stroke="#124458" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
<path d="M1.87781955,0.624324324 L1.87781955,5.61891892" id="Line-3"></path>
<path d="M7.76981857,0.624324324 L7.76981857,5.61891892" id="Line-3-Copy"></path>
<path d="M15.2810968,0.624324324 L15.2810968,5.61891892" id="Line-3-Copy-2"></path>
<path d="M22.792375,0.624324324 L22.792375,5.61891892" id="Line-3-Copy-3"></path>
</g>
<g id="Group-7" transform="translate(6.166667, 12.486486)" stroke="#124458" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
<path d="M1.87781955,0.535135135 L1.87781955,4.81621622" id="Line-3"></path>
<path d="M7.82424812,0.535135135 L7.82424812,4.81621622" id="Line-3-Copy"></path>
<path d="M15.3355263,0.535135135 L15.3355263,4.81621622" id="Line-3-Copy-2"></path>
<path d="M22.8468045,0.535135135 L22.8468045,4.81621622" id="Line-3-Copy-3"></path>
</g>
</g>
<g class="button">
<g id="Group-8-Copy" transform="translate(133.000000, 72.000000) rotate(44.000000) translate(-133.000000, -72.000000) translate(114.000000, 62.000000)">
<g id="Group-6" transform="translate(0.000000, -0.000000)">
<g id="Rectangle-9">
<use fill="#E8E8E8" xlink:href="#path-5"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-6)" xlink:href="#path-5"></use>
<path stroke="#124458" stroke-width="3" d="M9.42325581,3.62560386 C9.14711344,3.62560386 8.92325581,3.84946149 8.92325581,4.12560386 L8.92325581,18 C8.92325581,18.2761424 9.14711344,18.5 9.42325581,18.5 L28.9302326,18.5 C29.2063749,18.5 29.4302326,18.2761424 29.4302326,18 L29.4302326,4.12560386 C29.4302326,3.84946149 29.2063749,3.62560386 28.9302326,3.62560386 L9.42325581,3.62560386 Z" stroke-linejoin="square"></path>
</g>
<g id="Rectangle-9-Copy">
<use fill="#FF5963" xlink:href="#path-7"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-8)" xlink:href="#path-7"></use>
<path stroke="#124458" stroke-width="3" d="M6.39576918,2.24723609 C3.91048781,2.24723609 1.89576918,4.26195472 1.89576918,6.74723609 L1.89576918,12.6216322 C1.89576918,15.1069136 3.91048781,17.1216322 6.39576918,17.1216322 L31.5120482,17.1216322 C33.9973296,17.1216322 36.0120482,15.1069136 36.0120482,12.6216322 L36.0120482,6.74723609 C36.0120482,4.26195472 33.9973296,2.24723609 31.5120482,2.24723609 L6.39576918,2.24723609 Z" stroke-linejoin="square"></path>
</g>
</g>
</g>
</g>
<g id="Group-9" transform="translate(0.000000, 52.000000)">
<g id="Group-5">
<g id="Oval-6">
<use fill="#45ADEE" xlink:href="#path-9"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-10)" xlink:href="#path-9"></use>
<use stroke="#124458" stroke-width="3" xlink:href="#path-9"></use>
</g>
<g id="Oval-6">
<use fill="#F6F6F6" xlink:href="#path-11"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-12)" xlink:href="#path-11"></use>
<use stroke="#124458" stroke-width="3" xlink:href="#path-11"></use>
</g>
<ellipse id="Oval" fill="#FFFFFF" transform="translate(54.837645, 47.762128) rotate(-40.000000) translate(-54.837645, -47.762128) " cx="54.8376446" cy="47.7621279" rx="25.4593023" ry="15.4651163"></ellipse>
<ellipse id="Oval-Copy" fill="#FFFFFF" transform="translate(37.311047, 86.263018) rotate(-40.000000) translate(-37.311047, -86.263018) " cx="37.3110465" cy="86.2630178" rx="11.7827655" ry="12.6739538"></ellipse>
<path d="M74.622093,20.1649049 L74.622093,13.4164905 M103.661734,27.6663352 L107.035941,21.8220369 M123.496456,47.640592 L129.340754,44.2663848 M130.94556,76.8837209 L137.693975,76.8837209 M123.496456,104.359408 L129.340754,107.733615 M103.661734,125.217386 L107.035941,131.061684 M74.622093,132.718816 L74.622093,139.46723 M47.3382664,125.217386 L43.9640592,131.061684 M27.5035445,104.359408 L21.6592462,107.733615 M20.0544397,76.8837209 L13.3060254,76.8837209 M27.5035445,47.640592 L21.6592462,44.2663848 M47.3382664,27.6663352 L43.9640592,21.8220369" id="Line-2" stroke="#124458" stroke-width="3" stroke-linecap="round"></path>
</g>
<g class="timer">
<g id="Oval-6" stroke-linecap="round" stroke-linejoin="round">
<use fill="#45ADEE" xlink:href="#path-13"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-14)" xlink:href="#path-13"></use>
<use stroke="#124458" stroke-width="5" xlink:href="#path-13"></use>
</g>
<g id="Oval-6" stroke-linecap="round" stroke-linejoin="round">
<use fill="#45ADEE" xlink:href="#path-15"></use>
<use fill="black" fill-opacity="1" filter="url(#filter-16)" xlink:href="#path-15"></use>
<use stroke="#124458" stroke-width="3" xlink:href="#path-15"></use>
</g>
</g>
</g>
</g>
</g>
</svg>
<div class="credit">
| Made with <i class="fas fa-heart"></i> by <a class="credit__link" href="https://codepen.io/kaista/">Kaitlyn Stahl</a>
</div>
body
height 100vh
width 100vw
display grid
svg
place-self center
height 50%
.timer
transform-origin 16.5% 84%
transform-box fill-box
animation rotate 30s linear infinite running
.clicked
transform-origin 50% 50%
transform-box fill-box
animation click .25s linear forwards
.paused
animation-play-state paused
@keyframes rotate
to
transform rotate(360deg)
@keyframes click
50%
transform translate(-5px, 5px)
100%
transform translate(0px)
.credit {
position: fixed;
bottom: 2%;
right: 2%;
font-family: 'Lato', sans-serif;
text-transform: uppercase;
font-size: 0.7em;
color: #282a37;
}
.credit__link {
text-decoration: none;
color: #45ADEE;
}
.fa-heart {
color: #F57256;
}
var $el = $('.stopwatch'),
$timer = $el.find('.timer'),
$button = $el.find('.button');
$el.click(function() {
if ($timer.hasClass('paused')) {
$button.addClass('clicked');
setTimeout(function(){
$button.removeClass('clicked');
$timer.removeClass('paused');
}, 200);
}
else {
$button.addClass('clicked');
setTimeout(function(){
$button.removeClass('clicked');
$timer.addClass('paused');
}, 200);
}
})
Also see: Tab Triggers