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

165
Vistas
Can I append inline elements and align them to the left?

I am appending h4 elements to a div with the class of teamDisplay. I want the appended elements to be centered on the page but aligned to the left. For example, I want the alignment to look like this (aligned left)

            4. New York Giants
            5. Green Bay Packers
            6. Buffalo Bills

however, the appended elements are currently aligning to the center like so

           4. New York Giants
          5. Green Bay Packers
            6. Buffalo Bills

I have tested removing my appendInline class which then aligned everything to the left, however, all the appended elements appeared on separate lines rather than on one single line. In this question, the responders say that display: inline and text-align wouldn't have any affect together. I thought that I would be able to get past that by wrapping my appended inline elements in a div with display: inline-block and text-align: left, but to no avail.

// create elements
var teamNumber = document.createElement("h4");
var teamCityName = document.createElement("h4");
var teamMascotName = document.createElement("h4");
...
// assign elements "display: inline" property so they they all appear on the same line when they are appended together. This is where I run into the issue: I want the h4 elements to append on one line (that is why I use inline) and align to the left within the center inline-block div that they are being appended to, but instead they are currently aligning center
teamNumber.className = "appendInline";
teamCityName.className = "appendInline";
teamMascotName.className = "appendInline";
document.getElementById("newFavTeamDiv").append(teamNumber, teamCityName, " ", teamMascotName);
body {
  text-align: center;
}

.teamDisplay {
  display: inline-block;
  text-align: left;
}

.appendInline {
  display: inline;
}
<body>
  <div id="newFavTeamDiv" class="teamDisplay"></div>
</body>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

i do not know if you understand you question if i am wrong tell me more, you want to inline aling left three h4 element inside div element ? if you want this try it

.teamDisplay { display: flex; justify-content:flex-start;}

about 4 years ago · Juan Pablo Isaza 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