Nieuw lid |
|
beste masters,
ik heb een countdownklok script onderverdeeld in:
- javascript => berekening
- css => style
- html => getallen (dagen/uren/minuten/seconden)
in het javascript staat een datum waar naar toe afgeteld wordt alleen als deze datum is behaald komt er een tekst te staan, ik wil deze alleen opmaken met het CSS bestand, hier kom ik alleen niet uit
Javascript:
// JavaScript Document
var current="LET THE GAMES BEGIN"; //-->enter what you want the script to display when the target date and time are reached, limit to 20 characters
var year=2016; //-->YEAR
var month=8; //-->MONTH
var day=18; //-->DAY
var hour=17; //-->HOUR (24 hour clock)
var minute=00; //-->MINUTE
var tz=1; //-->Offset for your timezone in hours from UTC
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countdown(yr,m,d,hr,min){
theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min;
var today=new Date();
var todayy=today.getYear();
if (todayy < 1000) {todayy+=1900;}
var todaym=today.getMonth();
var todayd=today.getDate();
var todayh=today.getHours();
var todaymin=today.getMinutes();
var todaysec=today.getSeconds();
var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
var todaystring=Date.parse(todaystring1)+(tz*1000*60*60);
var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min);
var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60));
var dd=futurestring-todaystring;
var dday=Math.floor(dd/(60*60*1000*24)*1);
var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
document.getElementById('count2').innerHTML=current;
document.getElementById('count2').style.display="block";
document.getElementById('count2').style.width="390px";
document.getElementById('dday').style.display="none";
document.getElementById('dhour').style.display="none";
document.getElementById('dmin').style.display="none";
document.getElementById('dsec').style.display="none";
document.getElementById('days').style.display="none";
document.getElementById('hours').style.display="none";
document.getElementById('minutes').style.display="none";
document.getElementById('seconds').style.display="none";
document.getElementById('spacer1').style.display="none";
document.getElementById('spacer2').style.display="none";
return;
}
else {
document.getElementById('count2').style.display="none";
document.getElementById('dday').innerHTML=dday;
document.getElementById('dhour').innerHTML=dhour;
document.getElementById('dmin').innerHTML=dmin;
document.getElementById('dsec').innerHTML=dsec;
setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);
}
}
// JavaScript Document var current="LET THE GAMES BEGIN"; //-->enter what you want the script to display when the target date and time are reached, limit to 20 characters var year=2016; //-->YEAR var month=8; //-->MONTH var day=18; //-->DAY var hour=17; //-->HOUR (24 hour clock) var minute=00; //-->MINUTE var tz=1; //-->Offset for your timezone in hours from UTC var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); function countdown(yr,m,d,hr,min){ theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min; var today=new Date(); var todayy=today.getYear(); if (todayy < 1000) {todayy+=1900;} var todaym=today.getMonth(); var todayd=today.getDate(); var todayh=today.getHours(); var todaymin=today.getMinutes(); var todaysec=today.getSeconds(); var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec; var todaystring=Date.parse(todaystring1)+(tz*1000*60*60); var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min); var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60)); var dd=futurestring-todaystring; var dday=Math.floor(dd/(60*60*1000*24)*1); var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1); var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1); var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1); if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){ document.getElementById('count2').innerHTML=current; document.getElementById('count2').style.display="block"; document.getElementById('count2').style.width="390px"; document.getElementById('dday').style.display="none"; document.getElementById('dhour').style.display="none"; document.getElementById('dmin').style.display="none"; document.getElementById('dsec').style.display="none"; document.getElementById('days').style.display="none"; document.getElementById('hours').style.display="none"; document.getElementById('minutes').style.display="none"; document.getElementById('seconds').style.display="none"; document.getElementById('spacer1').style.display="none"; document.getElementById('spacer2').style.display="none"; return; } else { document.getElementById('count2').style.display="none"; document.getElementById('dday').innerHTML=dday; document.getElementById('dhour').innerHTML=dhour; document.getElementById('dmin').innerHTML=dmin; document.getElementById('dsec').innerHTML=dsec; setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000); } }
CSS:
@charset "UTF-8";
/* CSS Document */
body {
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#009cde+0,002d59+100 */
background: rgb(0,156,222); /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOWNkZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDJkNTkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgb(0,156,222) 0%, rgb(0,45,89) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgb(0,156,222) 0%,rgb(0,45,89) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgb(0,156,222) 0%,rgb(0,45,89) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#009cde', endColorstr='#002d59',GradientType=0 ); /* IE6-8 */
}
@font-face {
font-family: 'GoodPro-Normal';
src: url('GoodPro-Normal.eot');
src: url('GoodPro-Normal.eot?#iefix') format('embedded-opentype'),
url('GoodPro-Normal.woff') format('woff'),
url('GoodPro-Normal.ttf') format('truetype'),
url('GoodPro-Normal.svg#GoodPro-Normal') format('svg');
font-weight: normal;
font-style: normal;
}
#table {
width: 100%;
border: none;
margin: 0px;
position: relative;
height: 100%;
left: 0px;
}
.numbers {
border: none;
padding: 0px;
text-align: center;
font-family: 'GoodPro-Normal';
font-size: 624px;
font-style: normal;
color: #ffffff;
}
.title {
border: none;
padding: 0px;
text-align: center;
font-family: 'GoodPro-Normal';
font-size: 78px;
text-transform: uppercase;
letter-spacing: 12px;
color: #ffffff;
}
.hide {
display: none;
width:0px;
}
@charset "UTF-8"; /* CSS Document */ body { /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#009cde+0,002d59+100 */ background: rgb(0,156,222); /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOWNkZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwMDJkNTkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top, rgb(0,156,222) 0%, rgb(0,45,89) 100%); /* FF3.6-15 */ background: -webkit-linear-gradient(top, rgb(0,156,222) 0%,rgb(0,45,89) 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-gradient(to bottom, rgb(0,156,222) 0%,rgb(0,45,89) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#009cde', endColorstr='#002d59',GradientType=0 ); /* IE6-8 */ } @font-face { font-family: 'GoodPro-Normal'; src: url('GoodPro-Normal.eot'); src: url('GoodPro-Normal.eot?#iefix') format('embedded-opentype'), url('GoodPro-Normal.woff') format('woff'), url('GoodPro-Normal.ttf') format('truetype'), url('GoodPro-Normal.svg#GoodPro-Normal') format('svg'); font-weight: normal; font-style: normal; } #table { width: 100%; border: none; margin: 0px; position: relative; height: 100%; left: 0px; } .numbers { border: none; padding: 0px; text-align: center; font-family: 'GoodPro-Normal'; font-size: 624px; font-style: normal; color: #ffffff; } .title { border: none; padding: 0px; text-align: center; font-family: 'GoodPro-Normal'; font-size: 78px; text-transform: uppercase; letter-spacing: 12px; color: #ffffff; } .hide { display: none; width:0px; }
HTML
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/clock.js"></script>
</head>
<body>
<table id="table" border="0">
<tr id="spacer1">
<div id="count2" ></div>
<td align="center" ><div class="numbers" id="dday"></div><div class="title" id="days">Days</div></td>
<td align="center" ><div class="numbers hide" id="dhour"></div><div class="title hide" id="hours">Hours</div></td>
<td align="center" ><div class="numbers hide" id="dmin"></div><div class="title hide" id="minutes">Minutes</div></td>
<td align="center" ><div class="numbers hide" id="dsec"></div><div class="title hide" id="seconds">Seconds</div></td>
</tr>
</table>
</body>
<body onload="countdown(year,month,day,hour,minute)">
<link rel="stylesheet" type="text/css" href="css/style.css"> <table id="table" border="0"> <td align="center" ><div class="numbers" id="dday"></div><div class="title" id="days">Days </div></td> <td align="center" ><div class="numbers hide" id="dhour"></div><div class="title hide" id="hours">Hours </div></td> <td align="center" ><div class="numbers hide" id="dmin"></div><div class="title hide" id="minutes">Minutes </div></td> <td align="center" ><div class="numbers hide" id="dsec"></div><div class="title hide" id="seconds">Seconds </div></td> <body onload="countdown(year,month,day,hour,minute)">
mod edit: code tags
|