Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
JavaScript, el tamaño td siempre cambia

Estoy escribiendo un programa simple que incluye tablas y td. En el programa al pulsar q aparece el número uno en una td. pero cuando sucede, el ancho td cambia repentinamente. así que mi pregunta es ¿cómo detenerlo? aquí está el código:

 <html> <body> <table border = "1"> <tr> <td id = "td1"></td> <td id = "td2"></td> </tr> </table> <style> table { height: 400px; width: 800px; margin-left: auto; margin-right: auto; text-align: center; font-size:25px; } </style> </head> <head> <script> document.addEventListener("keydown", function(e){ if (e.key == "q") { document.getElementById("td1").innerHTML = "1"; } }); </script> </head> </html>

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

puede agregar la siguiente propiedad a su definición css

 table-layout: fixed; 

 <html> <body> <table border = "1"> <tr> <td id = "td1"></td> <td id = "td2"></td> </tr> </table> <style> table { height: 400px; width: 800px; margin-left: auto; margin-right: auto; text-align: center; font-size:25px; table-layout: fixed; } </style> </head> <head> <script> document.addEventListener("keydown", function(e){ if (e.key == "q") { document.getElementById("td1").innerHTML = "1"; } }); </script> </head>

about 4 years ago · Santiago Trujillo Denunciar

0

 <html> <head> <table border = "1"> <tr> <td id = "td1"></td> <td id = "td2"></td> </tr> </table> <style> table { height: 400px; width: 800px; margin-left: auto; margin-right: auto; text-align: center; font-size:25px; } td { width: 50%; } </style> </head> <body> <script> document.addEventListener("keydown", function(e){ if (e.key == "q") { document.getElementById("td1").innerHTML = "1"; } }); </script> </body> </html>

usa este código

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda