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="clock">
<div class="hours">
<span class="hour1">1</span>
<span class="hour2">2</span>
<span class="hour3">3</span>
<span class="hour4">4</span>
<span class="hour5">5</span>
<span class="hour6">6</span>
<span class="hour7">7</span>
<span class="hour8">8</span>
<span class="hour9">9</span>
<span class="hour10">10</span>
<span class="hour11">11</span>
<span class="hour12">12</span>
</div>
<div class="minutes">
<span class="min1">5</span>
<span class="min2">10</span>
<span class="min3">15</span>
<span class="min4">20</span>
<span class="min5">25</span>
<span class="min6">30</span>
<span class="min7">35</span>
<span class="min8">40</span>
<span class="min9">45</span>
<span class="min10">50</span>
<span class="min11">55</span>
<span class="min12">60</span>
</div>
<div class="seconds">
<span class="sec1">5</span>
<span class="sec2">10</span>
<span class="sec3">15</span>
<span class="sec4">20</span>
<span class="sec5">25</span>
<span class="sec6">30</span>
<span class="sec7">35</span>
<span class="sec8">40</span>
<span class="sec9">45</span>
<span class="sec10">50</span>
<span class="sec11">55</span>
<span class="sec12">60</span>
</div>
<div class="cover">
<div class="needle"></div>
<div class="bg"></div>
<div class="present">PRESENT</div>
<div class="past">PAST</div>
<div class="future">FUTURE</div>
<div class="center"></div>
</div>
</div>
@import compass
body
background: url(data:image/gif;base64,R0lGODlhFAAUAIAAAMDAwP///yH5BAEAAAEALAAAAAAUABQAAAImhI+pwe3vAJxQ0hssnnq/7jVgmJGfGaGiyoyh68GbjNGXTeEcGxQAOw==)
.clock
margin: auto
position: relative
overflow: hidden
font: 40px Monaco, MonoSpace
font-weight: bold
border: 3px solid #DDD
width: 300px
height: 300px
-webkit-border-radius: 150px
border-radius: 50%
-webkit-background-clip: padding-box
background-color: #FFF
-webkit-box-shadow: 0px 0px 30px 10px rgba(0,0,0,.7), inset 0px 0px 10px 5px rgba(0,0,0,.7)
.clock .hours, .clock .minutes, .clock .seconds
position: absolute
border-radius: 150px
-webkit-backface-visibility: hidden
.hours
height: 300px
width: 300px
top: 0px
left: 0px
+transform-origin(center, center)
span
margin-left: 120px
font-size: 40px
line-height: 55px
height: 150px
position: absolute
width: 60px
left: 0
top: 0
text-align: center
+transform-origin(bottom, center)
.minutes
height: 200px
width: 200px
left: 50px
top: 50px
+transform-origin(center, center)
-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8)
span
margin-left: 70px
font-size: 25px
line-height: 35px
height: 100px
position: absolute
width: 60px
left: 0
top: 0
text-align: center
+transform-origin(bottom, center)
.seconds
height: 130px
width: 130px
left: 85px
top: 85px
+transform-origin(center, center)
-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8)
span
margin-left: 35px
font-size: 15px
line-height: 25px
height: 65px
position: absolute
width: 60px
left: 0
top: 0
text-align: center
+transform-origin(bottom, center)
.cover
position: absolute
height: 300px
width: 300px
top: 1px
left: 1px
text-align: center
overflow: hidden
border-radius: 150px
.bg
position: relative
width: 0px
height: 0px
border-width: 149px
border-color: rgba(255,150,150,0.5) #BBB #BBB #BBB
border-style: solid
-webkit-border-radius: 150px
border-radius: 50%
.center
position: absolute
overflow: hidden
top: 110px
left: 110px
width: 80px
height: 80px
background-color: #911
border: 1px solid #911
-webkit-border-radius: 40px
border-radius: 50%
-webkit-box-shadow: 0px 0px 7px rgba(0,0,0,.9), inset 0px 0px 25px rgba(255,150,150,.9)
.present, .past, .future
-webkit-backface-visibility: hidden
-webkit-background-clip: padding-box
.present
position: absolute
top: 185px
width: 150px
height: 20px
color: #C33
text-align: right
font-size: 21px
line-height: 21px
+transform-origin(center, right)
+transform(rotate(-90deg))
.past
position: absolute
top: 140px
left: 4px
width: 105px
height: 45px
padding-left: 30px
color: #888
text-align: left
font-size: 18px
line-height: 25px
border-top: 1px solid red
-webkit-box-shadow: 1px -15px 20px -3px rgba(255,50,50,0.6)
+transform-origin(top, right)
+transform(rotate(45.5deg))
.past:before
content: ""
display: block
position: absolute
top: 8px
left: 4px
width: 6px
height: 6px
-webkit-border-radius: 3px
border-radius: 50%
background-color: #DDD
-webkit-box-shadow: 0px 0px 2px 1px black
.past:after
content: ""
display: block
position: absolute
top: 7px
right: 30px
width: 6px
height: 6px
-webkit-border-radius: 3px
border-radius: 50%
background-color: #DDD
-webkit-box-shadow: 0px 0px 2px 1px black
.future
position: absolute
top: 135px
left: 170px
width: 118px
height: 30px
padding-right: 17px
color: #888
text-align: right
font-size: 18px
line-height: 25px
border-top: 1px solid red
-webkit-box-shadow: -1px -15px 20px -3px rgba(255,50,50,0.6)
+transform-origin(center, left)
+transform(rotate(-45deg))
.future:after
content: ""
display: block
position: absolute
top: 8px
right: 4px
width: 6px
height: 6px
-webkit-border-radius: 3px
border-radius: 50%
background-color: #DDD
-webkit-box-shadow: 0px 0px 2px 1px black
.future:before
content: ""
display: block
position: absolute
top: 8px
left: 32px
width: 6px
height: 6px
-webkit-border-radius: 3px
border-radius: 50%
background-color: #DDD
-webkit-box-shadow: 0px 0px 2px 1px black
.needle
position: absolute
top: 25px
height: 135px
width: 5px
margin-left: 147px
background-color: #911
-webkit-border-radius: 5px
border-radius: 100% 100% 0 0
border: 1px solid #F22
-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,0.9)
body
padding: 50px
@for $i from 1 through 13
.hour#{$i}
+transform(rotate(($i*30)+deg))
.min#{$i}
+transform(rotate(($i*30)+deg))
.sec#{$i}
+transform(rotate(($i*30)+deg))
$(function() {
setInterval(function() {
var time = new Date(),
h = time.getHours(),
m = time.getMinutes(),
s = time.getSeconds(),
ms = time.getMilliseconds();
setHours(-((h+m/60)%12)*360/12);
setMinutes(-(m+s/60)*360/60);
setSeconds(-(s+ms/1000)*360/60);
}, 50);
function setHours(val) {
$('.hours').css('transform','rotate(' + parseInt(val, 10) + 'deg)');
}
function setMinutes(val) {
$('.minutes').css('transform','rotate(' + parseInt(val, 10) + 'deg)');
}
function setSeconds(val) {
$('.seconds').css('transform','rotate(' + parseInt(val, 10) + 'deg)');
}
});
Also see: Tab Triggers