0

I am relatively new to using CSS Grid. I've made a 12 column grid but i noticed when i view the grid in mobile it does not adapt to the mobile browser. My question is how can i make my grid responsive for mobile and tablet devices?

link to my code can be found here

.container > div {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2em;
  color: #ffeead;
}

html, body {
  box-sizing: border-box;
  background-color: #ffeead;
  height: 100%;
  padding: 10px;
  margin: 0px;
  font-family: arial;
}

.container > div:nth-child(1n) {
  background-color: #96ceb4;    
}

.container > div:nth-child(2n) {
  background-color: #ff6f69;
}

.container > div:nth-child(3n) {
  background-color: #88d8b0;
}

.container > div:nth-child(4n) {
    background-color: orangered
}

.container > div:nth-child(5n) {
  background-color: #ffcc5c;
}


.container {
    height: 100%;
    display: grid;
    grid-gap: 3px;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: 40px auto 40px;
}

.header {
    grid-column: 1 / -1;
}

.menu {
    grid-column: 1/ 3
}

.content {
    grid-column: 3 / 8;
}

.content1 {
    grid-column: 8/-1
}

.footer {
    grid-column: 1 / -1;
}
user3574939
  • 819
  • 3
  • 17
  • 34
  • Does this answer your question? [Media Queries: How to target desktop, tablet, and mobile?](https://stackoverflow.com/questions/6370690/media-queries-how-to-target-desktop-tablet-and-mobile) – doğukan Jul 16 '20 at 14:43
  • i stumbled across the topic of auto-fit and minmax(). would i be able to use either of those properties to make my grid responsive in mobile and tablet? or is Media Queries the best way to accomplish what i am looking to do? – user3574939 Jul 16 '20 at 14:46
  • did you see this https://css-tricks.com/auto-sizing-columns-css-grid-auto-fill-vs-auto-fit/ and example here : https://gridbyexample.com/examples/example37/ ? – G-Cyrillus Jul 16 '20 at 14:52
  • i've tried using auto-fit and auto-fill but both break my layout when i resize to mobile or tablet. The positioning of my layout is similar to an actual website with a header, menu, content area and footer. – user3574939 Jul 16 '20 at 16:53

0 Answers0