So I'm creating a footer with styled components and we don't use classes like in normal css.
If I want to replicate the same CSS trick where we do this code below
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
How would I replicate this in a styled component? Is that even the correct way to do it?
Or would I need to create an App.css file and simply add it to my project?
Here's the typical code for a styled component in react
import styled from 'styled-components/macro';
export const Container = styled.div`
padding: 80px 60px;
background: black;
font-family: 'Nunito Sans', sans-serif;
@media (max-width: 1000px) {
padding: 70px 30px;
}
`;
Is it possible to add that * { box-sizing} code into my styled component or what is the proper way to implement that into my project?
You can use standard CSS properties, and styled components will add vendor prefixes should they be needed. Styled components are independent of each other, and you do not have to worry about their names because the library handles that for you.
You can override an existing styled-components component by passing it to the styled() constructor/wrapper. For example, suppose you have the following styled button element: const Button = styled.
A CSS Reset style sheet is a list of rules that 'reset' all of the default browser styles. We reset the browser styles for two primary reasons: Not all browsers apply the same default rules. They may be similar, but not exact.
import { createGlobalStyle } from 'styled-components'
const GlobalStyle = createGlobalStyle`
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
`
// in your app root
<React.Fragment>
<GlobalStyle />
<Navigation /> {/* example of other top-level stuff */}
</React.Fragment>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With