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

122
Vistas
Set text on the same y-aligment line

I've been stuck on this problem for hours.

This is my Header.js

  <div className="navbar-inner">
      <h2>Text1</h2>
      <h3>Text2</h3>
  </div>

This is my Header.css file:

.navbar-inner {
   margin: 0 auto;
   color: #fff;
   display: flex;
   width: 87vw;
   background-color: red;
   justify-content: space-between;
   vertical-align: sub;
}

This is what is shown:

enter image description here

I would like Text1 and Text2 to be aligned on the same y-line: enter image description here

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

0

You can give flex on h2 and h3 tag.

h2, h3 {
  display: flex;
  align-items: center;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

align-items is what you need for vertically aligning text when using flex box.

I also removed the margin from the h2 and h3 elements (it is there by default).

.navbar-inner {
   margin: 0 auto;
   color: #fff;
   display: flex;
   width: 87vw;
   background-color: red;
   justify-content: space-between;

   /* New styles */
   align-items: flex-end;
   padding: 5px;
}

h2, h3 {
  margin: 0;
}

You will probably need to adjust the padding to align it how you actually want it in terms of how close the text should be to the edges.

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