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

119
Visualizações
position a text element relative to another

I have a form that carries info from one HTML to another using local storage. Since this text changes based on what the user inputs on the first HTML, I have to find a way to add a text element that stays with the output. For example: if a user types "Luke" and submits, ideally the next page will say "Luke's" (the "'s" being the separate text element). Since the text might be longer e.g. Lukas or Lucius, the "'s" text element has to stay at the end of the previous one regardless of its length.

<h1 id="show">
<!-- this is where the output text shows -->
      </h1>
<h1 class="epic1">'s epic <!-- this is what i want to stick to the  end of the output element -->
</h1>

I should also add that this JS isn't working...

  <script>
      
      document.getElementById("show").textContent += "'s";
    </script>
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

You can use an :after pseudo element for this. Its defined content will be added to any element that has the class it refers to, and it will be automatically styled the same way as the element it's appended to:

.epic1:after {
  content: "'s epic";
}
<h1 class="epic1">Tom</h1>

about 4 years ago · Santiago Gelvez Relatório

0

Not sure if it's the best way, but I added a div with a new class around the show element and used the ::after in css to add content.

.hey ::after {
  font-weight: bold;
  color: black;
  content: "'s";
}
<div class="hey">
  <h1 id="show">
  </h1>
</div>

about 4 years ago · Santiago Gelvez 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