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

199
Vistas
Why can't target class in react

i can't target className in react. I try to target it with div className="navbar"> and .navbar { align-items: center; } but it doesnt work.

    div{
    display: block;
    background-color: rgb(211, 57, 57);
    font: sans-serif;
    color: #white; 
    
    
}
li {
    list-style: none;
    display: block;
    align-items: center;
}
ul {
    display: block;
    box-sizing: border-box;
}

.navbar {
    align-items: center;
}

and navbar.js `

`

import React from 'react'
import './Navbar.css'

const Navbar = () => {
    return (
        
            <div className="navbar">
                <ul className="ul">
                    
                    <li><a href="/home">Home</a></li>
                    <li><a href="/about">About</a></li>
                    <li><a href="/contact">Contact</a></li>
                    </ul>
            </div>
        
    )
}

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

0

The rule align-items: center; is connected to using Flexbox, on itself it won't do much. Edit to match:

.navbar {
  display: flex;
  align-items: center;
}

Also remember that the default way for flex is to arrange the children horizontally, and align-items moves the children vertically in that case. If you want the children to stack vertically, you should add flex-direction: column;

about 4 years ago · Juan Pablo Isaza Denunciar

0

Your index.html should look something like this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="/App.css">
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

React has nothing to do with your css. You can use react to modify your css and you can use npm packages like material-ui to do the styling for you. But since you are clearly not doing either of those things, the above solution is the correct one.

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