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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
</head>
<body>
<div id="loading">
<div class="todo-container">
<button class="hamburger">☰</button>
<button class="cross">˟</button>
</div>
<div class="todo-bar">
<input type="text" id="task" placeholder="type todo & hit enter">
<div class="todo-list" id="todos"></div>
</div>
<div class="weather">
<span class="display-weather text-right"></span>
<span class="weather-icon"></span>
<div class="display-location"></div>
</div>
<div id="monthDiv">
</select>
</div>
<div id="monthOutput">
<!-- <h1 id="monthName"></h1> -->
<h1 id="time"></h1>
<ul id="days">
</ul>
</div>
<footer>
<div>
<p class="quote-text"></p>
<p class="author-text"></p>
</div>
</footer>
</div>
*{
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html{
color: #FDF4F4;
font-family: "Lato", "Arial", "sans-serif";
font-size:20px;
font-weight: 300;
text-rendering: optimizeLegibility;
overflow: hidden;
background-size: cover;
background-repeat: no-repeat;
}
/* Weather */
.weather{
position: relative;
float: right;
}
.weather-icon{
color: #e67e22;
display: inline-block;
width:30px;
text-align: center;
font-size: 120%;
vertical-align: middle;
margin-top: -5px;
margin-right: 10px;
line-height:120%;
}
.display-weather{
margin-top: 10px;
display: inline-block;
font-family: 'Roboto',arial,sans-serif;
font-size: 120%;
}
.display-location{
font-family: 'Roboto',arial,sans-serif;
font-size: 120%;
margin-top: 5px;
}
footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1rem;
/* background-color: #efefef; */
text-align: center;
font-size:75%;
color: white;
font-weight: 300;
}
/* Declan styles for calendar */
#monthName {
text-align: center;
text-decoration: underline;
display: inline-block;
}
#time {
position: relative;
text-align: center;
}
div#monthOutput li{
/* background-color: rgba(243, 242, 242); */
background-color: rgba(71, 69, 69, 0);
height: 100px;
width: 150px;
margin: .5px;
text-decoration: none;
display: inline-block;
border-style: ridge;
border-width:.5px;
cursor: pointer;
}
#monthOutput {
padding: 70px;
}
h1 {
color: #ECECEC;
position: absolute;
}
#days{
color:white;
margin-top: 2em;
}
/* todos */
.todo-container{
position: absolute;
left:.31em;
top:.5em;
width: 3em;
padding: 1.5em;
border-radius: 100%;
transition: all .2s ease-out;
}
#todos{
color:black;
display: block;
/* background: rgba(0,0,0,.2); */
}
/* rgba(0,0,0,.5); */
#task{
/* background: rgba(255, 255, 255, 0.96); */
background: rgba(0,0,0,.5);
border: none;
font-size: 80%;
color: #fff;
border-radius: 6px;
width: 230px;
margin-left: 20px;
margin-top: 10px;
padding-left: 5px;
margin-bottom: 10px;
}
/* box-shadow:
inset 0 0 8px rgba(94, 93, 93, 0.06),
0 0 16px rgba(100, 99, 99, 0.1); */
input[type=text]{
color:black;
padding-left:10px;
}
.todo-bar{
/* margin-top:10px; */
margin-left: 17px;;
background: rgba(0, 0, 0, 0.5);
width: 275px;
position: absolute;
top: 5em; left: 1em;
max-height: 100%;
border-radius: 4px;
}
.todo-bar : hover{
}
div.todo-list ul{
margin: 0;
padding: 0;
width: auto;
list-style: none;
}
div.todo-list li{
cursor: pointer;
position: relative;
padding: 2px 20px 12px 20px;
width:275px;
font-size: 80%;
transition: all 0.2s ease-out;
color:white;
letter-spacing: .5px;
list-style: none;
}
.hamburger,
.cross{
font-size: 120%;
cursor: pointer;
position: absolute;
background:transparent;
color:white;
border:0;
opacity: 0%;
padding: 5px 15px 5px 15px;
font-size: bold;
transition: all 2s ease out;
}
button:focus {outline:0;}
.hamburger,
.cross :hover{
font-size: 120%;
cursor: pointer;
position: absolute;
background:transparent;
color:white;
border:none;
opacity: 100%;
}
/* remove button */
.remove{
position: absolute;
right:10px;
margin-left:10px;
margin-right: 15px;
width:15px;
height:15px;
padding-top:.2px;
cursor: pointer;
}
.taskCompleted{
text-decoration: line-through;
color:black;
}
//todo list
//retrieve todo's from localStorage.Retun an empty array if no list is found
//localStorage are key/valye pairs and always stored as strings. Always parse them
//to a valid JS object before using them
var elDays = document.getElementById('days');
var elList = document.querySelector('ul');
var elH1 = document.querySelector('h1');
var select = document.querySelector('select');
var d = new Date();
// var today = date.getDate() + "_" + (date.getMonth()+1) + "_" + date.getFullYear();
//changes background from day to night from 6:00pm to 6 a.m.
function updateBackground(){
var hour = d.getHours();
if(hour > 6 && hour < 18)
document.body.style.backgroundImage = "url('images/day.jpg')";
else
document.body.style.backgroundImage = "url('images/darkSky.jpg')";
}
updateBackground();
//takes month for creating calendar
var monthArray = new Array(12);
monthArray[0] = "January";
monthArray[1] = "Febuary";
monthArray[2] = "March";
monthArray[3] = "April";
monthArray[4] = "May";
monthArray[5] = "June";
monthArray[6] = "July";
monthArray[7] = "August";
monthArray[8] = "September";
monthArray[9] = "October";
monthArray[10] = "November";
monthArray[11] = "December";
var utcMonth = monthArray[d.getUTCMonth()];
//updates the date every second
function updateClock(){
var date = new Date();
var n = date.toDateString();
var time = date.toLocaleTimeString();
var elTime = document.getElementById('time');
timeContent = elTime.innerHTML;
elTime.innerHTML = n + ' ' + time;
}
setInterval(updateClock, 1000);
//creates a calendar depending upon which month it is
function createCalendar(days, choice){
elList.innerHTML = '';
elH1.textContent = utcMonth;
var days = 31;
if(choice === 'February'){
days = 28;
} else if(choice === 'April' || choice === 'June' || choice === 'September' || choice === 'November'){
days = 30;
}
for(var i = 1; i <= days; i++) {
var elListItem = document.createElement('li');
elListItem.textContent = i;
elList.appendChild(elListItem);
}
}
createCalendar();
var date = new Date(); // current date
var dateClicked = date.getDate() + "_" + (date.getMonth()+1) + "_" + date.getFullYear();
var month = (date.getMonth())+1; //current month
var year = date.getFullYear(); //current year
//get todo's from localStorage
function get_todos(){
var todos = [];
var todos_str = localStorage.getItem(dateClicked);
if(todos_str !=null){
todos = JSON.parse(todos_str);
}
return todos;
}
// Adding a new TODO entry
function add(){
var todos = get_todos();
var task = $('#task').val();
var taskObj = {
task:task,
isDone:false,
};
todos.push(taskObj);
localStorage.setItem(dateClicked,JSON.stringify(todos));
//update list of the TODO's displayed on webpage
show();
$("input").val("");
//avoid any further actions generated by 'click' event
return false;
}
//remove the to-do list items from localStorage
function removeStorage(){
var todos = get_todos();
var id = event.currentTarget.getAttribute('id');
todos.splice(id,1);
localStorage.setItem(dateClicked,JSON.stringify(todos));
show();
return false;
}
//update localStorage for completed tasks
function updateLocalStorage(val){
var todos = get_todos();
for(var i=0;i<todos.length;i++){
if(todos[i].task === val){
todos[i].isDone = true;
}
}
localStorage.setItem(dateClicked,JSON.stringify(todos));
}
//display the current todo list on webpage
function show(){
var todos = get_todos();
var html="<ul>";
for(var i=0; i<todos.length; i++) {
var addClassStr = todos[i].isDone ? 'class=taskCompleted' : '';
html+= '<li ' + addClassStr + ' value='+ todos[i].task + '>' + todos[i].task + '<button class="remove" id="' + i + '">x</button></li>';
}
html+="</ul>";
$("#todos").html(html);
$(".remove").click(function(event){
event.currentTarget.parentElement.remove();
removeStorage();
});
$("#todos").on('click','li',function(){
$(this).addClass("taskCompleted");
updateLocalStorage($(this).attr("value"));
});
}
$("input").keydown(function(e){
if( $(this).val()!=="" && e.keyCode===13){
event.preventDefault();
add();
}
});
$(".todo-bar").hide();
$(".cross").hide();
$(".hamburger").click(()=>{
$(".todo-bar").slideToggle( "slow", ()=> {
$( ".hamburger" ).hide();
$( ".cross" ).show();
});
});
$(".cross").click(()=>{
$(".todo-bar").slideToggle("slow",()=>{
$(".cross").hide();
$(".hamburger").show();
});
});
$("#days").click(function(event){
// $(".todo-bar").slideToggle( "slow", function() {
// $( ".hamburger" ).hide();
// $( ".cross" ).show();
// });
$(".todo-bar").show("slow",function(){
$(".hamburger").hide();
$(".cross").show();
});
dateClicked = $(event.target).text()+ "_" + month + "_" + year;
show();
//console.log(id);
});
$(document).ready(function(){
document.getElementById("todo-bar").onload = function(){
show();
};
});
show();
Also see: Tab Triggers