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

164
Visualizações
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 Respostas
Responde à pergunta

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 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