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="de" >
<head>
<meta charset="UTF-8">
<title>Klausuren Countdown Rechner</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="page-wrapper">
<h1>Wann ist deine Klausur?</h1>
<p id="msg"></p>
<input type="date" id="date" x-webkit-speech value="2018-02-09">
<button onclick="submitDate()">Bestätigen</button>
</div>
<h1>Wieviel Zeit du noch hast!</h1>
<div id="clockdiv">
<div><span class="days"></span><div class="smalltext">Tage</div></div>
<div><span class="hours"></span><div class="smalltext">Stunden</div></div>
<div><span class="minutes"></span><div class="smalltext">Minuten</div></div>
<div><span class="seconds"></span><div class="smalltext">Sekunden</div></div>
<h3 class="status-container">Status: <span class="status-output"></span></h3>
</div>
<div id="progress" class="circle">
<div class="fill">
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
body{
text-align: center;
background: white;
font-family: sans-serif;
font-weight: 100;
}
h1{
color: #3B5998;
font-weight: 100;
font-size: 40px;
margin: 40px 0px 20px;
}
h3{
color: #3B5998;
font-weight: 100;
font-size: 20px;
margin: 40px 0px 20px;
}
a{
display: inline-block;
color: #fff;
font-size: 20px;
padding: 20px;
background: white;
border-radius: 10px;
text-decoration: none;
}
a:hover{
background: #3B5998;
}
#clockdiv{
font-family: sans-serif;
color: #fff;
display: inline-block;
font-weight: 100;
text-align: center;
font-size: 30px;
}
#page-wrapper {
font-family: sans-serif;
color: #fff;
display: inline-block;
font-weight: 100;
text-align: center;
font-size: 30px;
}
#clockdiv > div{
padding: 10px;
border-radius: 3px;
background: lightblue;
display: inline-block;
}
#clockdiv div > span{
padding: 15px;
border-radius: 3px;
background: #3B5998;
display: inline-block;
}
.smalltext{
padding-top: 5px;
font-size: 16px;
}
.status-output {
color: black;
}
.circle{
position: absolute;
left:50%;
transform:translateX(-50%);
width: 200px;
height: 200px;
background: #bdc3c7;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;
overflow: hidden;
}
#progress {
opacity: 0;
visibility: hidden;
transition: all 0.6s;
}
.fill{
position: absolute;
bottom: 0;
width: 100%;
height: 0%;
background: #3B5998;
transition: all 0.6s;
}
.score{
position: absolute;
width: 100%;
top: 50px;
text-align: center;
font-family: Arial, sans serif;
color: #fff;
font-size: 40pt;
line-height: 0;
font-weight: normal;
}
var clock = document.getElementById('clockdiv'); // Variable clock entspricht dem Element clockdiv
//berechnet Spannweite
var days_span = clock.querySelector('.days');
var status_output = clock.querySelector('.status-output');
var hours_span = clock.querySelector('.hours'); //variable wird definiert zur Ausgabe des ersten Elements aus".hours"
var minutes_span = clock.querySelector('.minutes');
var seconds_span = clock.querySelector('.seconds');
var progressElement = document.getElementById('progress');
var timeinterval;
//time_remaining(startTime) berechnet die verbleibende Zeit für den Countdown. Dazu werden über Date.parse die Millisekunden des
// Wertes des divs "date" eingelesen. Im folgenden wird deswegen von den Millisekunden aus die Sekunden, Minuten, Stunden, Tage berechnet.
function time_remaining(startTime){
var t = Date.parse(document.getElementById("date").value) - startTime;
var seconds = Math.floor( (t/1000) % 60 );
var minutes = Math.floor( (t/1000/60) % 60 );
var hours = Math.floor( (t/(1000*60*60)) % 24 );
var days = Math.floor( t/(1000*60*60*24) );
return {'total':t, 'days':days, 'hours':hours, 'minutes':minutes, 'seconds':seconds};
}
//setStatus(days) setzt den Status in Verbindung mit den verbleibenden Tagen und ordnet die Statusmeldung zu. Dazu wird aus der Konsole die Tage Anzahl ausgegeben und dann durch eine bedingte Funktion die entsprechende Meldung ausgegeben.
function setStatus(days) {
if (days < 1) {
status_output.innerHTML = 'Viel Glück und Erfolg!';
}
else if (days == 1) {
status_output.innerHTML = 'Morgen!!!!!!';
}
else if (days <= 4) {
status_output.innerHTML = 'Jetzt aber!!';
}
else if (days < 8) {
status_output.innerHTML = 'Nur noch eine Woche!';
}
else {
status_output.innerHTML = 'Alles okay';
}
}
// function submitDate updatet die Countdown Daten und gibt sie über days_span.innerHtml in dem HTML Dokument aus. Der Countdown wird mit einer bedingten Funktion beendet, damit er nicht in den Minus Bereich geht.
function submitDate() {
clearInterval(timeinterval);
timeinterval = setInterval(function update_clock(){
var t = time_remaining(Date.parse(new Date()));
// upadatet die Zahlen in der Uhr
days_span.innerHTML = t.days;
hours_span.innerHTML = ('0' + t.hours).slice(-2);
minutes_span.innerHTML = ('0' + t.minutes).slice(-2);
seconds_span.innerHTML = ('0' + t.seconds).slice(-2);
setStatus(t.days);
setProgress(t.days);
if(t.total<=0){ clearInterval(timeinterval); }
}, 1000);
}
// Funktioniert definiert den Füllstand des Status Kreises. variable dayPercent berechnet dazu den % Satz der Steigung pro Tag. progressPercent den genauen Stand pro Tag. Falls es länger als 7 Tage bis zur Klausur ist wird der Kreis versteckt.
function setProgress(days) {
var fillElement = document.getElementById('progress').querySelector('.fill');
if (days <= 7) {
var dayPercent = 100 / 7;
var progressPercent = 100 - dayPercent * days;
progressElement.style.visibility = 'visible';
progressElement.style.opacity = '1';
fillElement.style.height = progressPercent + '%';
}
else {
progressElement.style.visibility = 'hidden';
progressElement.style.opacity = '0';
fillElement.style.height = '0%';
}
}
Also see: Tab Triggers