React CSS Grid

Creating our app

npx create-react-app my-react-grid
cd my-react-grid
code .

Cleaning up our app:
Delete everything in our App.js
add four divs:
1) Container
2)header
3)main body
4)footer
it should look like this once you’re done.

i…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by raboomar

  1. Creating our app
npx create-react-app my-react-grid  
cd my-react-grid
code .
  1. Cleaning up our app: Delete everything in our App.js add four divs: 1) Container 2)header 3)main body 4)footer it should look like this once you're done.
import "./App.css";

function App() {
  return (
    <div className="grid-container">
      <div className="header-container">Header</div>
      <div className="body-container">body</div>
      <div className="footer-container">Footer</div>
    </div>
  );
}

export default App;

Next is cleaning up our app.css:
Delete everything and add the following code:

.grid-container {
  display: grid;
  grid-template-areas:
    "header header header header header header"
    "body body body body body body"
    "footer footer footer footer footer footer";
  gap: 10px;
  padding: 10px;
}

.header-container {
  grid-area: header;
}
.body-container {
  grid-area: body;
  height: 100vh;
}
.footer-container {
  grid-area: footer;
}

The grid template area is where we establish the cells in the grid and assign them names.
grid-area property specifies a grid item's size and location in a grid layout.
Giving the body a height of 100vh allows it to take the maximum height, pushing the header to the top and the footer to the bottom.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by raboomar


Print Share Comment Cite Upload Translate Updates
APA

raboomar | Sciencx (2022-09-25T22:43:25+00:00) React CSS Grid. Retrieved from https://www.scien.cx/2022/09/25/react-css-grid/

MLA
" » React CSS Grid." raboomar | Sciencx - Sunday September 25, 2022, https://www.scien.cx/2022/09/25/react-css-grid/
HARVARD
raboomar | Sciencx Sunday September 25, 2022 » React CSS Grid., viewed ,<https://www.scien.cx/2022/09/25/react-css-grid/>
VANCOUVER
raboomar | Sciencx - » React CSS Grid. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/25/react-css-grid/
CHICAGO
" » React CSS Grid." raboomar | Sciencx - Accessed . https://www.scien.cx/2022/09/25/react-css-grid/
IEEE
" » React CSS Grid." raboomar | Sciencx [Online]. Available: https://www.scien.cx/2022/09/25/react-css-grid/. [Accessed: ]
rf:citation
» React CSS Grid | raboomar | Sciencx | https://www.scien.cx/2022/09/25/react-css-grid/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.