Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
¿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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!