Cambiar tamaño y color de texto cada 5 segundos
Publicado por Cesar (4 intervenciones) el 10/03/2020 07:20:55
requiere de una pagina donde el texto cambie cada 5 segundo de tamaño y color
Valora esta pregunta


0
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="miTexto">Texto que cambia cada 5 segundos</div>
</body>
</html>
<script>
const miTexto=document.getElementById("miTexto");
setInterval(() => {
r=Math.floor(Math.random() * 255);
g=Math.floor(Math.random() * 255);
b=Math.floor(Math.random() * 255);
size=Math.floor(Math.random() * 50)+1;
miTexto.style.color="rgb("+r+","+g+","+b+")";
miTexto.style.fontSize=size+"px";
}, 5000);
</script>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<style>
.negrita {font-weight:bold;}
.cursiva {font-style:italic;}
.tachado {text-decoration:line-through;}
</style>
</head>
<body>
<div id="miTexto">Texto que cambia cada 5 segundos</div>
</body>
</html>
<script>
const miTexto=document.getElementById("miTexto");
let valorEstilo=0;
setInterval(() => {
r=Math.floor(Math.random() * 255);
g=Math.floor(Math.random() * 255);
b=Math.floor(Math.random() * 255);
size=Math.floor(Math.random() * 50)+1;
miTexto.style.color="rgb("+r+","+g+","+b+")";
miTexto.style.fontSize=size+"px";
miTexto.classList.remove("negrita", "cursiva", "tachado");
miTexto.classList.add(["negrita", "cursiva", "tachado"][valorEstilo++]);
if (valorEstilo==3) valorEstilo=0;
}, 5000);
</script>