Translate

segunda-feira, 18 de novembro de 2013

Cronometro / contador regressivo em HTML e CSS

Cronometro / contador regressivo

Começa a pisca trocar de cor quando faltar 10min
Copia e cola o codigo html no Bloco de Notas e salva da seguinte forma:

nomedoarquivo.html

Copiar e cola o Código CSS los hum Documento Fazer Bloco de Notas e salva da seguinte forma:

estilo.css

Os Dois TEM Que Estar Salvo na MESMA pasta

Parte HTML

<DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="estilo.css" type="text/css" rel="stylesheet" />
<title> Documento sem título </ title>
<script>
SEGUNDOS var = ;/ 70/1800; / / Inicio fazer cronometro
função formatatempo (segs) {

min = 0;
hr = 0;
/ *
se hr <10 então hr = "0" & ​​hr
se min <10 min, em seguida = "0" & ​​min
se segs <10 então segs = "0" e segs
* /
while (segs> = 60) {
if (segs> = 60) {
segs = segs-60;
min = min +1;
}
}

while (min> = 60) {
if (min> = 60) {
min = min-60;
hr = 1 hr;
}
}
if (FC <10) {hr = "0" + h}
if (min <10) {min = "0" + min}
if (segs <10) {segs = "0" + segs}
fin = h + ":" + min + ":" + segs
voltar fin;
}


<- Função Conta () {
<- SEGUNDOS -;
!.. <- Documento getElementById ("contador") innerHTML = formatatempo (SEGUNDOS);
<-!}


Conta função () {
SEGUNDOS -;

var ritmo = formatatempo (SEGUNDOS);
if (0 min ==) {

. document.getElementById ("contador") style.color = "vermelho";

document.getElementById ("contador") innerHTML =''.;

setTimeout (function () {
document.getElementById ("contador") innerHTML = ritmo.;
}, 500
);

if (SEGUNDOS == 0) {
alert ("Tempo de Apresentação esgotado!");
n ();
stop ();
}
} Else {
document.getElementById ("contador") innerHTML = ritmo.;
}
}


Inicia a função () {
if (SEGUNDOS == 0) {
alert ("Tempo de Apresentação esgotado!");
clearInterval (intervalo);
stop ();
} Else {
intervalo = setInterval ("Conta ();", 1000);}
}


função para () {
clearInterval (intervalo);}


função zera () {
clearInterval (intervalo);
SEGUNDOS = 1800;
. document.getElementById ("contador") style.color = "branco";
. document.getElementById ("contador") innerHTML = formatatempo (SEGUNDOS);
}
</ Script>


<- <script>
SEGUNDOS var = 1800
var VELOCIDADE = 1000;
var valor = 1;
função pisca () {
SEGUNDOS -;
if (valor == 1) {
counter.innerHTML = formatatempo (SEGUNDOS);
valor = 0;
} Else {
counter.innerHTML = "";
valor = 1;
}
setTimeout ("pisca ();", VELOCIDADE);
}
</ Script> ->


<script>
local var = "cronometro"
/ * VALORES = liga UO Desliga * /

var Alerta = "Desliga"

if (screen.width == 1280 && == Screen.Height 1024)
{This.location = local + '1280x1024. Html '}

if (screen.width == 1280 && == Screen.Height 960)
{This.location = local + '1280x960. Html '}

if (screen.width == 1280 && == Screen.Height 768)
{This.location = local + '1280x768. Html '}

if (screen.width == 1280 && == Screen.Height 720)
{This.location = local + '1280x720. Html '}

if (screen.width == 1152 && == Screen.Height 864)
{This.location = local + '1152x864. Html '}

if (screen.width == 1024 && == Screen.Height 768)
{Top.location = local + '1024x768. Html '}

if (screen.width == 848 && Screen.Height == 480)
{This.location = local + '848x480. Html '}

if (screen.width == 800 && Screen.Height == 600)
{This.location = local + '800x600. Html '}

if (screen.width == 640 && Screen.Height == 480)
{This.location = local + '640x480. Html '}

if (Alerta == 'liga') {
alert ('SUAS configurações de video FORAM detectadas com Êxito:' + screen.width + '×' + Screen.Height + 'pixels \ n \ nRedirecionando ...')}
else {}

</ Script>

</ Head>

<Onload corpo = "pisca ();" >
<div id="imagem" align="center">
<div id="a"> </ div>
<div id="b"> <img src="imagens/3 Oficina Engenharia.png" width="800" height="450" ​​/> </ div>
<div id="a"> </ div>
</ Div>
<div id="dir">
<div id="logo">
</ Div>
<div id="cronometro" align="center">
<span id="counter" class="blink"> 00:30:00 </ span> <br />
        <div> <input type="button" value="Parar" onclick="para();">
        <input type="button" value="Iniciar" onclick="inicia();">    
        <input type="button" value="Recomeçar" onclick="zera();"> </ div>
     
</ Div>

</ Div>

</ Body>
</ Html>


Parte CSS

body {
margin: 0px;
border: 0px;
altura: 100%;
background-size: 100%;
font-size: 110px;
fonte: Arial, Helvetica, sans-serif;
/ * Inicio se degradam do Corpo * /
background-color: # 2F2727;
background-image: url (images / radial_bg.png);
background-position: center;
background-repeat: no-repeat;

/ * Safari 4-5, 1-9 Chrome * / / * Não é possível especificar um tamanho de porcentagem? Laaaaaame. * /
background:-webkit-gradiente (radial, centro, 0, centro, 460, a partir de (# 1a82f7), para (# 2F2727));

/ * Safari 5.1 +, Chrome 10 + * /
background:-webkit-radial-gradiente (círculo, # 1a82f7, # 2F2727);

/ * Firefox 3.6 + * /
background:-moz-radial-gradiente (círculo, # 1a82f7, # 2F2727);

/ * IE 10 * /
fundo:-ms-radial-gradiente (círculo, # 1a82f7, # 2F2727);
/ * Fim se degradam do Corpo * /}

corpo, html {
altura: 100%;
width: 100%;
}

# Imagem {
width: 65%;
altura: 100%;
float: left;
vertical-align: central;
}

# Dir {width: 35%;
altura: 100%;
float: right;}

# {Cronometro
width: 100%;
altura: 20%;
font-size: 90px;
font-family: "Arial Black", Gadget, sans-serif;
color: # FFF;
line-height: 50px;
text-decoration: blink;
}

# {Logotipo

width: 100%;}





Contador regressivo / Cronômetro </ title></font></font></p> <p> <br /> </p> <p> <font><font><script></font></font></p> <p> </p> <p> <font><font>SEGUNDOS var = 3600 ;/ / 1800; </font><font>/ / Inicio Fazer cronometro</font></font></p> <p> </p> <p> <font><font>função formatatempo (segs) {</font></font></p> <p>     </p> <p> <font><font>min = 0;</font></font></p> <p> <font><font>hr = 0;</font></font></p> <p> <font><font>/ *</font></font></p> <p> <font><font>se FC <10 entao hr = "0" e hr</font></font></p> <p> <font><font>Si min <10 min, em SEGUIDA = "0" & ​​min</font></font></p> <p> <font><font>segs si <10 Segs entao = "0" E Segs</font></font></p> <p> <font><font>* /</font></font></p> <p> <font><font>while (segs> = 60) {</font></font></p> <p> <font><font>if (segs> = 60) {</font></font></p> <p> <font><font>segs = segs-60;</font></font></p> <p> <font><font>min = min +1;</font></font></p> <p> <font><font>}</font></font></p> <p> <font><font>}</font></font></p> <p> </p> <p> <font><font>while (min> = 60) {</font></font></p> <p> <font><font>if (min> = 60) {</font></font></p> <p> <font><font>min = min-60;</font></font></p> <p> <font><font>hr = 1 Hora;</font></font></p> <p> <font><font>}</font></font></p> <p> <font><font>}</font></font></p> <p> <font><font>if (FC <10) {hr = "0" + h}</font></font></p> <p> <font><font>if (min <10) {min = "0" + min}</font></font></p> <p> <font><font>if (segs <10) {segs = "0" + segs}</font></font></p> <p> <font><font>fin = h + ":" + min + ":" + Segs</font></font></p> <p> <font><font>voltar fin;</font></font></p> <p> <font><font>}</font></font></p> <p> </p> <p> </p> <p> <font><font><- Função Conta () {</font></font></p> <p> <font><font><- SEGUNDOS -;</font></font></p> <p> <font><font>! </font><font>.. <- Documento getElementById ("contador") innerHTML = formatatempo (SEGUNDOS);</font></font></p> <p> <font><font><-!}</font></font></p> <p> </p> <p> <font><font>Conta função () {</font></font></p> <p> <font><font>SEGUNDOS -;</font></font></p> <p> </p> <p> <font><font>var ritmo = formatatempo (SEGUNDOS);</font></font></p> <p> <font><font>if (SEGUNDOS <= 600) {</font></font></p> <p>     </p> <p> <font><font>    . </font><font>document.getElementById ("contador") style.color = "# 2FFF2F";</font></font></p> <p>         </p> <p> <font><font>    document.getElementById ("contador") innerHTML =''.;</font></font></p> <p> </p> <p> <font><font>    setTimeout (function () {</font></font></p> <p> <font><font>        document.getElementById ("contador") innerHTML = ritmo.;</font></font></p> <p> <font><font>    }, 500</font></font></p> <p> <font><font>    );</font></font></p> <p>     </p> <p> <font><font>        if (SEGUNDOS <= 300) {</font></font></p> <p> <font><font>        . </font><font>document.getElementById ("contador") style.color = "# FFFA1A";</font></font></p> <p>             </p> <p> <font><font>        document.getElementById ("contador") innerHTML =''.;</font></font></p> <p>     </p> <p> <font><font>        setTimeout (function () {</font></font></p> <p> <font><font>            document.getElementById ("contador") innerHTML = ritmo.;</font></font></p> <p> <font><font>        }, 500</font></font></p> <p> <font><font>        );    </font></font></p> <p> <font><font>                if (SEGUNDOS <= 150) {</font></font></p> <p> <font><font>            . </font><font>document.getElementById ("contador") style.color = "# FF0F09";</font></font></p> <p>                 </p> <p> <font><font>            document.getElementById ("contador") innerHTML =''.;</font></font></p> <p>         </p> <p> <font><font>            setTimeout (function () {</font></font></p> <p> <font><font>                document.getElementById ("contador") innerHTML = ritmo.;</font></font></p> <p> <font><font>            }, 500</font></font></p> <p> <font><font>            );    </font></font></p> <p> <font><font>            if (SEGUNDOS == 0) {</font></font></p> <p> <font><font>                . </font><font>document.getElementById ("contador") innerHTML = formatatempo (SEGUNDOS);</font></font></p> <p> <font><font>                n ();</font></font></p> <p> <font><font>                stop ();    </font></font></p> <p> <font><font>    }}}</font></font></p> <p> <font><font>} Else {</font></font></p> <p> <font><font>    document.getElementById ("contador") innerHTML = ritmo.;</font></font></p> <p> <font><font>}</font></font></p> <p> <font><font>}</font></font></p> <p> </p> <p> <font><font>Inicia UMA função () {</font></font></p> <p> <font><font>if (SEGUNDOS == 0) {</font></font></p> <p> <font><font>    alert ("Tempo de Apresentação esgotado!");</font></font></p> <p> <font><font>    stop ();</font></font></p> <p> <font><font>}</font></font></p> <p> <font><font>Intervalo = setInterval ("Conta ();", 1000);</font></font></p> <p> <font><font>}</font></font></p> <p> </p> <p> <font><font>função para () {</font></font></p> <p> <font><font>    if (SEGUNDOS == 0) {</font></font></p> <p> <font><font>clearInterval (Intervalo);</font></font></p> <p> <font><font>alert ("Tempo de Apresentação esgotado!")}</font></font></p> <p> <font><font>else {</font></font></p> <p> <font><font>    clearInterval (Intervalo);}</font></font></p> <p> <font><font>}</font></font></p> <p> </p> <p> <font><font>função zera () {</font></font></p> <p> </p> <p> <font><font>clearInterval (Intervalo);</font></font></p> <p> <font><font>SEGUNDOS = 3600;</font></font></p> <p> <font><font>. </font><font>document.getElementById ("contador") innerHTML = formatatempo (SEGUNDOS);</font></font></p> <p> <font><font>. </font><font>document.getElementById ("contador") style.color = "Branco";</font></font></p> <p> </p> <p> <font><font>}</font></font></p> <p> <font><font></ Script></font></font></p> <p> </p> <p> <font><font></ Head></font></font></p> <p> </p> <p> <font><font><onload Corpo = "pisca ();" </font><font>></font></font></p> <p> <font><font><div id="a"> </ div></font></font></p> <p> <font><font><div align="center"> <img id="imagem" src="imagens/3 Oficina Engenharia.png" width="300" height="169" /> </ div></font></font></p> <p> <font><font><div id="a"> </ div></font></font></p> <p> <font><font><div id="botoes" align="center"> </font></font></p> <p> <font><font><table width="100%" border="0" align="center"></font></font></p> <p> <font><font> <tr></font></font></p> <p> <font><font>    <td align="center" height="50px"> <input type="button" value="Parar" onclick="para();"> </font></font></p> <p> <font><font>        <input type="button" value="Iniciar" onclick="inicia();">      </font></font></p> <p> <font><font>        <input type="button" value="Recomeçar" onclick="zera();"> </ td></font></font></p> <p> <font><font>  </ Tr></font></font></p> <p> <font><font>  </ Table> </font></font></p> <p> <font><font></ Div></font></font></p> <p> <font><font><div id="cronometro" align="center"> </font></font></p> <p> <font><font>  <table width="100%" border="0" align="center"></font></font></p> <p> <font><font> <tr></font></font></p> <p> <font><font>    <td align="center" height="360px"> <span id="counter" class="blink"> <- 00:30:00 -> </ span> </ td></font></font></p> <p> <font><font>  </ Tr></font></font></p> <p> <font><font></ Table>            </font></font></p> <p> <font><font></ Div></font></font></p> <p> <font><font></ Div></font></font></p> <p> <font><font></ Body></font></font></p> <p> <font><font></ Html></font></font></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <h2> <b><font><font>Parte CSS</font></font></b></h2> <p> </p> <p> <font><font>body {</font></font></p> <p> <font><font>    margin: 0px;</font></font></p> <p> <font><font>    border: 0px;</font></font></p> <p> <font><font>    Altura: 100%;</font></font></p> <p> <font><font>    background-size: 100%;</font></font></p> <p> <font><font>    font-size: 110px;</font></font></p> <p> <font><font>    fonte: Arial, Helvetica, sans-serif;</font></font></p> <p> <font><font>    / * Inicio se degradam do Corpo * /</font></font></p> <p> <font><font>    background-color: # 2F2727;</font></font></p> <p> <font><font>    background-image: url (images / radial_bg.png); </font></font></p> <p> <font><font>    background-position: center; </font></font></p> <p> <font><font>    background-repeat: no-repeat; </font></font></p> <p>     </p> <p> <font><font>    / * Safari 4-5, 1-9 Chrome * / / * Localidade: Não E Possível Localidade: Não Especificado hum tamanho de porcentagem? </font><font>Laaaaaame. </font><font>* /</font></font></p> <p> <font><font>    background:-webkit-gradiente (radial, centro, 0, centro, 460, a Partir de (# 1a82f7), Pará (# 2F2727)); </font></font></p> <p>     </p> <p> <font><font>    / * Safari 5.1 +, Chrome 10 + * / </font></font></p> <p> <font><font>    background:-webkit-radial-gradiente (Círculo, # 1a82f7, # 2F2727); </font></font></p> <p>     </p> <p> <font><font>    / * Firefox 3.6 + * / </font></font></p> <p> <font><font>    background:-moz-radial-gradiente (Círculo, # 1a82f7, # 2F2727); </font></font></p> <p>     </p> <p> <font><font>    / * IE 10 * / </font></font></p> <p> <font><font>    Fundo:-ms-radial-gradiente (Círculo, # 1a82f7, # 2F2727); </font></font></p> <p> <font><font>    / * Fim se degradam do Corpo * /}</font></font></p> <p>     </p> <p> <font><font>Corpo, html {</font></font></p> <p> <font><font>    Altura: 100%;</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>}</font></font></p> <p>     </p> <p> <font><font># Imagem {</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>    Altura: 30%;</font></font></p> <p> <font><font>    vertical-align: central;</font></font></p> <p> <font><font>    }</font></font></p> <p> </p> <p> </p> <p> <font><font># {Cronometro</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>    Altura: 50%;</font></font></p> <p> <font><font>    font-size: 250px;</font></font></p> <p> <font><font>    font-family: Arial Black, Gadget, sans-serif;</font></font></p> <p> <font><font>    color: # FFF;</font></font></p> <p> <font><font>    text-decoration: blink;</font></font></p> <p> <font><font>    }</font></font></p> <p>     </p> <p> <font><font># {BOTOES</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>    font-size: 30px;</font></font></p> <p> <font><font>    font-family: "Arial Black", Gadget, sans-serif;</font></font></p> <p> <font><font>    color: # FFF;</font></font></p> <p> <font><font>    text-decoration: blink;</font></font></p> <p> <font><font>    }</font></font></p> <p>     </p> <p> <font><font># {Logotipo</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>    height: 70%;</font></font></p> <p> <font><font>    }</font></font></p> <p> <font><font># A {</font></font></p> <p> <font><font>    width: 100%;</font></font></p> <p> <font><font>    height: 2%;</font></font></p> <p> <font><font>    }</font></font></p> <p> <font><font># Contador {text-decoration: blink;} </font></font></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p>

Nenhum comentário:

Postar um comentário