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 id='watch'>
<!-- The bands of the watch -->
<div id='tlg' class='grip'></div>
<div id='trg' class='grip'></div>
<div id='blg' class='grip'></div>
<div id='brg' class='grip'></div>
<div id='topBand' class='band'></div>
<div id='botBand' class='band'></div>
<!-- // bands -->
<!-- The Face of the watch -->
<div id='face'>
<div id='glass'>
<div id='twelve'>XII</div>
<div id='three'>III</div>
<div id='six'>VI</div>
<div id='nine'>IX</div>
<div id='center'>
<div id='name'>shadiblanc</div>
<div id='smallHand'></div>
<div id='midHand'></div>
<div id='bigHand'></div>
<div id='dot'></div>
<div id='desc'>automatic</div>
</div>
</div>
</div>
<!-- // face -->
</div>
body{ overflow: hidden; }
/* line 3, ../sass/s.scss */
#watch {
position: relative;
margin: 50px;
}
/* Bands */
/* Grippers */
/* line 11, ../sass/s.scss */
.grip {
position: absolute;
border: 1px solid #777;
width: 12px;
height: 30px;
background: #eee;
}
/* line 18, ../sass/s.scss */
#tlg {
top: -11px;
left: 50px;
border-radius: 8px 4px 0 0;
border-left: none;
box-shadow: inset 0 1px 0px #444444, inset 0 2px 0 white, inset 0 -6px 3px #444444;
}
/* line 25, ../sass/s.scss */
#trg {
top: -11px;
left: 150px;
border-radius: 4px 8px 0 0;
border-right: none;
box-shadow: inset 0 1px 0 #444444, inset 0 2px 0 white, inset 0 -6px 3px #444444;
}
/* line 32, ../sass/s.scss */
#blg {
top: 151px;
left: 50px;
border-radius: 0 0 4px 8px;
border-left: none;
box-shadow: inset 0 -1px 0px #444444, inset 0 -2px 0 white, inset 0 6px 3px #444444;
}
/* line 39, ../sass/s.scss */
#brg {
top: 151px;
left: 150px;
border-radius: 0 0 8px 4px;
border-left: none;
box-shadow: inset 0 -1px 0px #444444, inset 0 -2px 0 white, inset 0 6px 3px #444444;
}
/* Material */
/* line 47, ../sass/s.scss */
.band {
background: linear-gradient(27deg, #151515 5px, transparent 5px) 0 5px,
linear-gradient(207deg, #151515 5px, transparent 5px) 10px 0px,
linear-gradient(27deg, #222 5px, transparent 5px) 0px 10px,
linear-gradient(207deg, #222 5px, transparent 5px) 10px 5px,
linear-gradient(90deg, #1b1b1b 10px, transparent 10px),
linear-gradient(#1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424);
background-color: #131313;
background-size: 20px 20px;
width: 87px;
height: 600px;
position: absolute;
}
/* line 54, ../sass/s.scss */
#topBand {
top: -80px;
left: 63px;
}
/* line 59, ../sass/s.scss */
#botBand {
top: 140px;
left: 63px;
}
/* Starting with the face of the watch */
/* line 65, ../sass/s.scss */
#face {
background-color: #fefefe;
*zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFEFEFE', endColorstr='#FFFFFFFF');
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fefefe), color-stop(17%, #dbd9da), color-stop(50%, #0b0d0c), color-stop(51%, #0b0e0c), color-stop(59%, #b0b1b5), color-stop(71%, #aeadbd), color-stop(84%, #cfcfcd), color-stop(100%, #ffffff));
background-image: -webkit-linear-gradient(top, #fefefe 0%, #dbd9da 17%, #0b0d0c 50%, #0b0e0c 51%, #b0b1b5 59%, #aeadbd 71%, #cfcfcd 84%, #ffffff 100%);
background-image: -moz-linear-gradient(top, #fefefe 0%, #dbd9da 17%, #0b0d0c 50%, #0b0e0c 51%, #b0b1b5 59%, #aeadbd 71%, #cfcfcd 84%, #ffffff 100%);
background-image: -o-linear-gradient(top, #fefefe 0%, #dbd9da 17%, #0b0d0c 50%, #0b0e0c 51%, #b0b1b5 59%, #aeadbd 71%, #cfcfcd 84%, #ffffff 100%);
background-image: linear-gradient(top, #fefefe 0%, #dbd9da 17%, #0b0d0c 50%, #0b0e0c 51%, #b0b1b5 59%, #aeadbd 71%, #cfcfcd 84%, #ffffff 100%);
margin: 20px;
padding: 10px 0 0 10px;
width: 160px;
height: 160px;
border: 1px solid #999;
border-radius: 50%;
box-shadow: inset 0 0 3px #000;
position: relative;
}
/* line 78, ../sass/s.scss */
#face:after {
content: " ";
display: block;
width: 14px;
height: 22px;
position: absolute;
right: -15px;
top: 74px;
z-index: -9;
border-radius: 10px;
border: 1px solid #888;
background-color: #aaa;
*zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFFFFFF', endColorstr='#FF282828');
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(7%, #505050), color-stop(14%, #c5c7c6), color-stop(22%, #505050), color-stop(28%, #e6e4e7), color-stop(35%, #8d8c91), color-stop(42%, #e9e9e9), color-stop(49%, #8c8c8c), color-stop(57%, #e2e2e4), color-stop(65%, #c8c8c8), color-stop(72%, #808080), color-stop(76%, #b4b4b4), color-stop(85%, #fdfdfd), color-stop(92%, #b4b4b4), color-stop(100%, #282828));
background-image: -webkit-linear-gradient(top, #ffffff 0%, #505050 7%, #c5c7c6 14%, #505050 22%, #e6e4e7 28%, #8d8c91 35%, #e9e9e9 42%, #8c8c8c 49%, #e2e2e4 57%, #c8c8c8 65%, #808080 72%, #b4b4b4 76%, #fdfdfd 85%, #b4b4b4 92%, #282828 100%);
background-image: -moz-linear-gradient(top, #ffffff 0%, #505050 7%, #c5c7c6 14%, #505050 22%, #e6e4e7 28%, #8d8c91 35%, #e9e9e9 42%, #8c8c8c 49%, #e2e2e4 57%, #c8c8c8 65%, #808080 72%, #b4b4b4 76%, #fdfdfd 85%, #b4b4b4 92%, #282828 100%);
background-image: -o-linear-gradient(top, #ffffff 0%, #505050 7%, #c5c7c6 14%, #505050 22%, #e6e4e7 28%, #8d8c91 35%, #e9e9e9 42%, #8c8c8c 49%, #e2e2e4 57%, #c8c8c8 65%, #808080 72%, #b4b4b4 76%, #fdfdfd 85%, #b4b4b4 92%, #282828 100%);
background-image: linear-gradient(top, #ffffff 0%, #505050 7%, #c5c7c6 14%, #505050 22%, #e6e4e7 28%, #8d8c91 35%, #e9e9e9 42%, #8c8c8c 49%, #e2e2e4 57%, #c8c8c8 65%, #808080 72%, #b4b4b4 76%, #fdfdfd 85%, #b4b4b4 92%, #282828 100%);
}
/* line 94, ../sass/s.scss */
#glass {
box-shadow: inset 0 0 6px #000;
background: #a6a39e;
*zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFC8C5C0', endColorstr='#FFADA8A2');
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #c8c5c0), color-stop(100%, #ada8a2));
background-image: -webkit-linear-gradient(top, #c8c5c0 0%, #ada8a2 100%);
background-image: -moz-linear-gradient(top, #c8c5c0 0%, #ada8a2 100%);
background-image: -o-linear-gradient(top, #c8c5c0 0%, #ada8a2 100%);
background-image: linear-gradient(top, #c8c5c0 0%, #ada8a2 100%);
width: 150px;
height: 150px;
border: 1px solid #999;
border-radius: 80px;
position: relative;
/* Numbers */
}
/* line 107, ../sass/s.scss */
#glass div {
position: absolute;
font-size: 14px;
}
/* line 111, ../sass/s.scss */
#glass div:nth-child(2n) {
transform: rotate(-90deg);
}
/* line 115, ../sass/s.scss */
#glass #twelve {
top: 3px;
left: 65px;
}
/* line 116, ../sass/s.scss */
#glass #three {
top: 66px;
left: 135px;
}
/* line 117, ../sass/s.scss */
#glass #six {
top: 135px;
left: 67px;
}
/* line 118, ../sass/s.scss */
#glass #nine {
top: 66px;
left: 5px;
}
/* line 121, ../sass/s.scss */
#glass #center {
background: #e1ddd2;
box-shadow: inset 0 1px 1px #777777, inset 0 -1px 1px #777777;
width: 110px;
height: 110px;
border-radius: 50%;
top: 20px;
left: 20px;
}
/* line 130, ../sass/s.scss */
#glass #center div {
top: 55px;
left: 55px;
}
/* line 134, ../sass/s.scss */
#glass #center #name, #glass #center #desc {
top: 10px;
left: 32px;
font-variant: small-caps;
font-size: 8px;
}
/* line 140, ../sass/s.scss */
#glass #center #desc {
top: 70px;
margin-left: 4px;
transform: none;
}
/* line 146, ../sass/s.scss */
#glass #center #dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #444e5e;
*zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FF444E5E', endColorstr='#FF4F4E5E');
left: 51px;
top: 55px;
}
/* line 156, ../sass/s.scss */
#glass #center #smallHand, #glass #center #midHand, #glass #center #bigHand {
background: #1c2252;
width: 45px;
height: 2px;
border: 1px solid #4f4e5e;
box-shadow: 0 0 1px #b5afaf;
/* enables antialiasing */
border-radius: 80%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
transform-origin: 0% 50%;
transform: rotate(-45deg);
-webkit-animation: hours 43200s infinite linear;
-moz-animation: hours 43200s infinite linear;
-ms-animation: hours 43200s infinite linear;
-o-animation: hours 43200s infinite linear;
animation: hours 43200s infinite linear;
}
/* line 169, ../sass/s.scss */
#glass #center #bigHand {
width: 65px;
height: 0;
border-bottom: none;
-webkit-animation: seconds 60s infinite linear;
-moz-animation: seconds 60s infinite linear;
-ms-animation: seconds 60s infinite linear;
-o-animation: seconds 60s infinite linear;
animation: seconds 60s infinite linear;
}
/* line 175, ../sass/s.scss */
#glass #center #midHand {
width: 65px;
height: 1px;
-webkit-animation: minutes 3600s infinite linear;
-moz-animation: minutes 3600s infinite linear;
-ms-animation: minutes 3600s infinite linear;
-o-animation: minutes 3600s infinite linear;
animation: minutes 3600s infinite linear;
}
/* keyframes added with JS so that watch starts at local time */
@-webkit-keyframes seconds {0%{-webkit-transform: rotate(120deg);}to{-webkit-transform: rotate(480deg);}}
@-webkit-keyframes minutes {0%{-webkit-transform: rotate(178deg);}to{-webkit-transform: rotate(538deg);}}
@-webkit-keyframes hours {0%{-webkit-transform: rotate(130deg);}to{-webkit-transform: rotate(490deg);}}
@-moz-keyframes seconds {0%{-moz-transform: rotate(120deg);}to{-moz-transform: rotate(480deg);}}
@-moz-keyframes minutes {0%{-moz-transform: rotate(178deg);}to{-moz-transform: rotate(538deg);}}
@-moz-keyframes hours {0%{-moz-transform: rotate(130deg);}to{-moz-transform: rotate(490deg);}}
@-o-keyframes seconds {0%{-o-transform: rotate(120deg);}to{-o-transform: rotate(480deg);}}
@-o-keyframes minutes {0%{-o-transform: rotate(178deg);}to{-o-transform: rotate(538deg);}}
@-o-keyframes hours {0%{-o-transform: rotate(130deg);}to{-o-transform: rotate(490deg);}}
@-ms-keyframes seconds {0%{-ms-transform: rotate(120deg);}to{-ms-transform: rotate(480deg);}}
@-ms-keyframes minutes {0%{-ms-transform: rotate(178deg);}to{-ms-transform: rotate(538deg);}}
@-ms-keyframes hours {0%{-ms-transform: rotate(130deg);}to{-ms-transform: rotate(490deg);}}
@keyframes seconds {0%{transform: rotate(120deg);}to{transform: rotate(480deg);}}
@keyframes minutes {0%{transform: rotate(178deg);}to{transform: rotate(538deg);}}
@keyframes hours {0%{transform: rotate(130deg);}to{transform: rotate(490deg);}}
/*
http://thesisb.com
Realistic wristwatch in pure HTML/CSS
---
No images!
CSS texture for the band borrowed from http://lea.verou.me/css3patterns/
Idea by Brian Shumate - http://news.ycombinator.com/item?id=4373036
---
Click details above and drop a comment/suggestion/critique
*/
/**
* The following JS is only added to start
* the time at your local time.
*/
var d = new Date(),
hr = d.getHours()%12,
min = d.getMinutes(),
sec = d.getSeconds(),
// Base Values (-90 since that's where 12 starts)
baseDegSEC = -90 + Math.round(sec * 6),
baseDegMIN = -90 + Math.round(min*6 + (6 / (60/sec))),
baseDegHR = -90 + Math.round(hr*30 + (30 / ( (60/min)+(60/sec) )) ),
// End Values
endDegSEC = baseDegSEC + 360,
endDegMIN = baseDegMIN + 360,
endDegHR = baseDegHR + 360,
keyframes = "",
VENDORS = [ '-webkit-', '-moz-', '-o-', '-ms-', '' ];
for( var i = 0, len = VENDORS.length; i < len; i++ ) {
keyframes += "@"+VENDORS[i]+"keyframes seconds {"+
"0%{"+VENDORS[i]+"transform: rotate("+baseDegSEC+"deg);}"+
"to{"+VENDORS[i]+"transform: rotate("+endDegSEC+"deg);}}"+
"@"+VENDORS[i]+"keyframes minutes {"+
"0%{"+VENDORS[i]+"transform: rotate("+baseDegMIN+"deg);}"+
"to{"+VENDORS[i]+"transform: rotate("+endDegMIN+"deg);}}"+
"@"+VENDORS[i]+"keyframes hours {"+
"0%{"+VENDORS[i]+"transform: rotate("+baseDegHR+"deg);}"+
"to{"+VENDORS[i]+"transform: rotate("+endDegHR+"deg);}}";
}
// Add the Keyframes in a <style> tag in the <head>
var cssAnimation = document.createElement('style');
cssAnimation.type = 'text/css';
var rules = document.createTextNode(keyframes);
cssAnimation.appendChild(rules);
document.getElementsByTagName("head")[0].appendChild(cssAnimation);
// Reloading the stylesheets to fix Chrome bug?
var links = document.getElementsByTagName("link");
for (var i = 0; i < links.length; i++) {
var link = links[i];
if (link.rel === "stylesheet") {
link.href += "?";
}
}
Also see: Tab Triggers