كيفاش تزيد coming soon page للموقع ديالك مع العد التنازلي
نظرة سريعة بالفيديو
1- الملف index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>cOMING sOON</title>
</head>
<body>
<header>
<img src="logo.png" class="logo" alt="" height="100">
<h1>Coming Soon</h1>
<div class="line"></div>
<ul class="list-items">
<li class="item" id="days">
</li>
<li class="item" id="hours">
</li>
<li class="item" id="min">
</li>
<li class="item" id="sec">
</li>
</ul>
</header>
<script src="main.js"></script>
</body>
</html>
2- الملف main.js
var count = new Date("Mar 30, 2018 15:37:25").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var dist = count- now;
var days = Math.floor(dist / (1000 * 60 * 60 * 24));
var hours = Math.floor((dist % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((dist % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((dist % (1000 * 60)) / 1000);
document.getElementById("days").textContent = days + 'j';
document.getElementById("hours").textContent = hours + 'h';
document.getElementById("min").textContent = minutes + 'm';
document.getElementById("sec").textContent = seconds + 's';
if (distance < 0) {
clearInterval(x);
}
}, 1000);
3- الملف style.css
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
text-align: center;
height: 100%;
}
header{
background: linear-gradient(to right,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url('bg.jpg');
background-size: cover;
background-position: center;
height: 100vh;
color: #fff;
text-transform: uppercase;
position: relative;
}
h1{
position: absolute;
letter-spacing: 8px;
top: 40%;
left: 40%;
}
.line{
height: 2px;
width: 60px;
color: #fff;
border-style: solid;
border-color: #fff;
border-width: 2px;
position: absolute;
letter-spacing: 8px;
top: 50%;
left: 49%;
}
ul.list-items{
margin: 40px 0;
position: absolute;
letter-spacing: 8px;
top: 50%;
left: 36%;
}
ul.list-items{
list-style: none;
}
ul.list-items li{
display: inline-block;
margin-left: 10px;
padding: 10px;
text-align: center;
color: #fff;
font-size: 25px;
font-weight: 700;
text-transform:uppercase;
background-color: orange;
border-radius: 5px;
}
.logo{
position: absolute;
top: 20%;
left: 49%;
}