Untitled
2 years ago in CSS
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Bebas+Neue" rel="stylesheet">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>greeting2</title>
<style>
/*CSS RESETS*/
body{
background-color: #FFFFFF;
line-height: 1.6;
}
h1 {
margin-top: 0;
}
/*CSS START*/
.full-table {
display: table;
height: 100%;
width: 100%;
}
.table-cell {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.card {
padding: 10px 25px 10px 25px;
border-radius: 10px;
background: #EE95BA;
width: 85vw;
color: #fff;
display: inline-block;
box-shadow: 2px 2px 1px 0px #DB6B99;
}
.card:hover {
margin-top: 2px;
box-shadow: none;
}
.clock {
display:inline;
font-family: 'Times New Roman', cursive;
font-size: 1.4em;
}
.time {
display: inline;
min-width: 37px;
}
.colon {
font-size: 1em;
display: inline-block;
}
.date {
display: inline-block;
min-width: 162px;
font-family: 'Times New Roman', cursive;
font-size: 1.4em;
padding-right: 10px;
}
.greet{
display:inline;
font-family: 'Dancing Script', cursive;
font-size: 1.85rem;
padding-right: 10px;
}
</style>
</head>
<body>
<div class="full-table">
<div class="table-cell">
<div class="card">
<div class="greet" id="greet"></div>
<div class="date" id="date"></div>
<div class="clock">
<div class="time" id="hour"></div>
<div class="colon">:</div>
<div class="time" id="min"></div>
<div class="colon">:</div>
<div class="time" id="sec"></div>
</div>
</div>
</div>
</div>
<script>
function date() {
var today = new Date();
document.getElementById('date').innerHTML = today.toDateString();
}
function clock() {
var today = new Date();
var hour = zeros(twentyfourHour(today.getHours()));
var minutes = zeros(today.getMinutes());
var seconds = zeros(today.getSeconds());
if(today.getHours() >=12){
}
hrs = today.getHours();
if (hrs < 24)
greet = '𐇵 Good Morning Ang 𐇵';
else if (hrs >= 12 && hrs <= 17)
greet = '𐇵 Good Afternoon Ang 𐇵';
else if (hrs >= 17 && hrs <= 24)
greet = '𐇵 Good Evening Ang 𐇵';
// console.log(today.toLocaleTimeString());
document.getElementById('greet').innerHTML = greet;
document.getElementById('hour').innerHTML = hour;
document.getElementById('min').innerHTML = minutes;
document.getElementById('sec').innerHTML = seconds;
}
function twentyfourHour(hour) {
if (hour > 24) {
return hour -= 24
} else if (hour == 24) {
return hour = 0;
} else {
return hour
}
}
// adds zero infront of single digit number
function zeros(num) {
if (num < 10) {
num = '0' + num
};
return num;
}
function dateTime() {
date();
clock();
setTimeout(dateTime, 500);
}
dateTime()
// END
</script>
</body>
<html>