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.
<!DOCTYPE html>
<html lang="en">
<head>
<!--==== Design by foolish developer (foolishdeveloper.com) ===-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style media="screen">
@import url("https://fonts.googleapis.com/css?family=Orbitron");
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: border-box;
outline: none;
}
body {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
background-color: #080710;
height: 100vh;
}
.background{
width: 430px;
height: 520px;
position: absolute;
transform: translate(-50%,-50%);
left: 50%;
top: 50%;
}
.background .shape{
height: 140px;
width: 140px;
position: absolute;
border-radius: 50%;
}
.shape:first-child{
background: linear-gradient(
#1845ad,
#23a2f6
);
left: -80px;
top: 70px;
}
.shape:last-child{
background: linear-gradient(
to right,
#ff512f,
#f09819
);
right: -80px;
bottom: 80px;
}
.alarm-clock {
position: relative;
padding: 7px;
backdrop-filter: blur(10px);
border-radius: 10px;
background-color: rgba(255,255,255,0.17);
}
.alarm-clock .date {
position: absolute;
bottom: 1px;
left: 50%;
background-color: rgba(255,255,255,0.27);
padding: 8px;
color: white;
font-size: 18px;
font-weight: 500;
font-family: sans-serif;
text-transform: uppercase;
transform: translateX(-50%);
z-index: 9;
}
.alarm-clock .time {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 20px 40px 19px;
background-color: rgba(255,255,255,0.13);
border-radius: 10px;
font-family: "Orbitron", sans-serif;
font-size: 62px;
}
.alarm-clock .time span {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
color: #09ecf8;
text-shadow: 0 0 15px #375f08;
line-height: 1.75;
margin-bottom: 10px;
}
.alarm-clock .time span:nth-of-type(5) {
width: 90px;
}
.alarm-clock .time span.colon {
width: 14px;
padding: 15px;
text-align: center;
animation: blink 2s infinite;
}
@keyframes blink {
0% {
opacity: 0;
}
30% {
opacity: 1;
}
50% {
opacity: 0;
}
70% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>
</head>
<body>
<div class="background">
<div class="shape"></div>
<div class="shape"></div>
</div>
<div class="alarm-clock">
<div class="date">
<span class="month"></span>
<span class="day"></span>,
<span class="year"></span>
</div>
<div class="time">
<span class="hours"></span>
<span class="colon"> :</span>
<span class="minutes"></span>
<span class="colon"> : </span>
<span class="seconds"></span>
</div>
</div>
<script type="text/javascript">
//Need to determine the constant of some id functions.
//No html function can be used directly in JavaScript
const hours = document.querySelector('.hours');
const minutes = document.querySelector('.minutes');
const seconds = document.querySelector('.seconds');
const month = document.querySelector('.month');
const day = document.querySelector('.day');
const year = document.querySelector('.year');
function setDate() {
//The "new Date" method helps to get the current time from the device
const now = new Date();
// Now the information of month, day, year has to be received from the device
const mm = now.getMonth();
const dd = now.getDate();
const yyyy = now.getFullYear();
//Now the information of sec, min, hours has to be received from the device
const secs = now.getSeconds();
const mins = now.getMinutes();
const hrs = now.getHours();
//I have stored the names of all the months in the constant named "monthName"
const monthName = [
'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'];
//Zero will be added when the time is below 10
//As a result, time will always be two characters long
if (hrs < 10) {
hours.innerHTML = '0' + hrs;
} else {
hours.innerHTML = hrs;
}
if (secs < 10) {
seconds.innerHTML = '0' + secs;
} else {
seconds.innerHTML = secs;
}
if (mins < 10) {
minutes.innerHTML = '0' + mins;
} else {
minutes.innerHTML = mins;
}
//"innerHTML" is used to display all the information in the webpage
month.innerHTML = monthName[mm];
day.innerHTML = dd;
year.innerHTML = yyyy;
}
//All of the above calculations are stored in "setDate".
//Now with the help of "setInterval" that calculation has to be updated every 1 second. This will update the time every second.
//1 second = 1000 milliseconds
setInterval(setDate, 1000);
</script>
</body>
</html>
Also see: Tab Triggers