0
I am starting my studies/development with React but I have a problem in the stylization of the components. Even though importing the CSS file into my component, the style is not picking up. How can I fix this??
import React from 'react';
import './styles.css';
const Header = () => (
<header id="main-header">JShunt</header>
);
export default Header;
import React from 'react';
import './styles.css';
import Header from './components/Header';
const App = () => (
<div className="App">
<Header/>
<p>Bricando com React</p>
</div>
);
export default App;
header #main-header {
width: 100%;
height: 60px;
background: #da552f;
font-size: 18px;
font-weight: bold;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
as Carlos put it as an answer, check if the Styles.css file is in your Components/Header .Looking at your code you can assume that there are two Styles.css files, one in the same App folder and the other in the Header folder
– Paulo Souza
I edited the question by placing the directory screenshot. Yes, they are two styles: one of the componenente and the other is global
– Eric Rosário
Change the declaration of your class to
header#main-header {
and voila, if you want, you can even keep#main-header
– MarceloBoni
@Marceloboni. Perfect!! Had tried this way and was not there now yes. Anyway, thank you! Style applied
– Eric Rosário