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="c-timer">
<div class="c-timer__clock">
<div class="c-timer__clock--progress" style="--p: 75"></div>
<div class="c-timer__clock--face">
<h1 id="timer" class="c-timer__clock--time" contenteditable="true">15:00</h1>
<div class="c-timer__clock--button">
<button name="start" class="" type="button">start</button>
</div>
<div class="c-timer__clock--settings">
<button name="settings" class="" type="button" onclick="focusTimer()">
<svg id="icon-cog" aria-hidden="true" width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#filter0_d_108_7)"><path d="M28 14V10H23.714C23.526 9.274 23.238 8.592 22.866 7.962L25.898 4.93L23.07 2.1L20.04 5.132C19.406 4.76 18.726 4.472 18 4.284V0H14V4.284C13.274 4.474 12.594 4.76 11.96 5.134L8.93 2.1L6.102 4.928L9.132 7.96C8.762 8.592 8.472 9.272 8.286 10H4V14H8.286C8.474 14.726 8.762 15.408 9.134 16.038L6.102 19.072L8.93 21.9L11.962 18.868C12.594 19.24 13.274 19.528 14.002 19.718V24H18.002V19.716C18.728 19.526 19.408 19.238 20.042 18.866L23.074 21.898L25.902 19.07L22.87 16.036C23.242 15.406 23.53 14.726 23.718 13.998H28V14ZM16 16C13.792 16 12 14.206 12 12C12 9.796 13.792 8 16 8C18.208 8 20 9.796 20 12C20 14.204 18.208 16 16 16Z" fill="#ffffff"/></g><defs><filter id="filter0_d_108_7" x="0" y="0" width="32" height="32" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dy="4"/><feGaussianBlur stdDeviation="2"/><feComposite in2="hardAlpha" operator="out"/><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_108_7"/><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_108_7" result="shape"/></filter></defs></svg>
<span class="sr-only">settings</span>
</button>
</div>
</div>
</div>
</div>
@font-face {
font-family: 'Bebas Neue';
src: url('https://codepen.davidroessli.com/fonts/bebasneue-book-webfont.woff2') format('woff2'),
url('https://codepen.davidroessli.com/fonts/bebasneue-book-webfont.woff') format('woff');
}
:root {
--tool-color: #585858;
--tool-color-hover: white;
--clock-color: white;
--progress-color: #900A0A;
--clock-width: 500px;
--progress-width: 18px;
}
body {
background: radial-gradient(71.4% 71.4% at 51.7% 28.6%, #3A393F 0%, #17171A 100%);
color:#fff;
}
.c-timer {
height:100vh;
width:100vw;
display:flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.c-timer__clock {
position: relative;
width: var(--clock-width);
height: var(--clock-width);
border-radius: 50%;
background: radial-gradient(71.4% 71.4% at 51.7% 28.6%, #3A393F 0%, #17171A 100%);
box-shadow: inset 0px 0px 114px rgba(0, 0, 0, 0.45);
}
.c-timer__clock--progress {
width: var(--clock-width);
height: var(--clock-width);
background:conic-gradient(from 90deg, black calc((100 - var(--p)) * 1%), var(--progress-color) 0);
border-radius: 50%;
}
.c-timer__clock--face {
position: absolute;
top: calc(var(--progress-width) / 2);
left: calc(var(--progress-width) / 2);
width: calc(var(--clock-width) - var(--progress-width));
height: calc(var(--clock-width) - var(--progress-width));
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-radius: 50%;
background: radial-gradient(71.4% 71.4% at 51.7% 28.6%, #3A393F 0%, #17171A 100%);
box-shadow: inset 0px 0px 114px rgba(0, 0, 0, 0.45);
}
h1 {
font-family: 'Bebas Neue', sans-serif;
font-style: normal;
font-weight: normal;
font-size: 196px;
line-height: 196px;
text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
margin-top: 20%;
}
[name="start"] {
font-family: Montserrat;
font-style: normal;
font-weight: bold;
font-size: 16px;
line-height: 20px;
text-align: center;
letter-spacing: 0.6em;
text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
color: var(--clock-color);
text-transform:uppercase;
transition: transform 0.25s ease-in-out;
}
[name="start"]:focus,
[name="start"]:hover {
color: var(--tool-color-hover);
transform: scale(1.3);
}
[name="settings"] #icon-cog g path {
fill: var(--tool-color);
transition: fill 0.25s ease-in-out;
}
[name="settings"]:focus #icon-cog g path,
[name="settings"]:hover #icon-cog g path {
fill: var(--tool-color-hover);
}
/*
Not much functionality by lack of time -- this is the advent of CSS after all ;)
*/
focusTimer = function getFocus() {
document.getElementById("timer").focus();
}
Also see: Tab Triggers