Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
¿Cómo centro, cambio el color y la fuente de esta cadena?

No sé nada sobre codificación o desarrollo, así que si alguien pudiera volver a pegar mi código con las correcciones incluidas, sería increíblemente útil. Estoy agregando un widget de fecha actual a mi sitio web, pero no puedo centrarlo, cambiar el color de la fuente a blanco o cambiar la fuente en absoluto. ¿Alguien podría ayudarme?

Aquí está el código que estoy usando en su totalidad:

 let date = new Date(); let day = String(date.getDate()); let weekday = date.getDay(); let month = date.getMonth(); let year = String(date.getFullYear()); const monthNames = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] month = monthNames[month]; weekday = weekdays[weekday] let fullDate = (weekday + " " + day + ", " + month + ", " + year); document.write(fullDate);

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Como esto

Tenga en cuenta que envolví el script en un evento de carga de página

Cambie document.body.innerHTML += a, por ejemplo

document.getElementById("myDateContainer").innerHTML =

si tienes otro lugar donde ponerlo

myDateContainer podría estar <div id="myDateContainer"></div> en algún lugar de su página

 <!doctype html> <html> <head> <title>Some title</title> <style> .date { display: table; margin: 0 auto; color: red; font-family: Arial, Helvetica, sans-serif; } </style> <script> window.addEventListener("load", function() { let date = new Date(); let day = String(date.getDate()); let weekday = date.getDay(); let month = date.getMonth(); let year = String(date.getFullYear()); const monthNames = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] month = monthNames[month]; weekday = weekdays[weekday] let fullDate = (weekday + " " + day + ", " + month + ", " + year); document.body.innerHTML += `<span class="date">${fullDate}</span>`; }) </script> </head> <body> </body> </html>

about 4 years ago · Juan Pablo Isaza Relatório

0

**Para centrar agregue ** su etiqueta de estilo después de "color: rojo"

 <style> .date { display: flex; justify-content: center; align-items: center; } </style>

Su código eventualmente debería verse así: gracias a @mplungjan

 <html> <head> <title>Some title</title> <style> .date { display: flex; justify-content: center; align-items: center; color: red; font-family: Arial, Helvetica, sans-serif; } </style> </head> <script> window.addEventListener("load", function() { let date = new Date(); let day = String(date.getDate()); let weekday = date.getDay(); let month = date.getMonth(); let year = String(date.getFullYear()); const monthNames = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] month = monthNames[month]; weekday = weekdays[weekday] let fullDate = (weekday + " " + day + ", " + month + ", " + year); document.body.innerHTML += `<span class="date">${fullDate}</span>`; }) </script> </head> <body> </body> </html>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda