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

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

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 Relatório

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