0

The following header looks fine on full-width; but once I start sizing down; there's a large gap to the left of the ipsom lorem text, where it should be filling in the full-width of the screen as it sized down. (First picture is full-width; second picture is what should happen when it sizes down). enter image description here

2

Here is my code so far:

.header {
    background-color: #090c1a;
}

.header-inner {
  color: white;
  display: grid;
  max-width: 1180px;
  margin: 180px auto;
  grid-template-columns: 1fr minmax(50%, auto);
}

I've also created a codepen for convenience. https://codepen.io/tiotolstoy/pen/PoPzoQw

  • What exactly do you want it to look like on mobile screens? – Nick Kinlen Apr 17 '20 at 22:57
  • I'd like it to take up the full width instead of having padding to the right as it would with my current implementation. –  Apr 17 '20 at 23:04

2 Answers2

0

I don't think a grid is the best approach for what you described. I would do it with a "max-width: 590px" on the nested div inside the header-inner. like here - https://codepen.io/urich/pen/rNOLNZd

.header-inner {
  color: white;
  max-width: 1180px;
  margin: 180px auto;
}

.header-inner >div {
  max-width: 590px;
}
Uri Chachick
  • 432
  • 2
  • 6
  • This implementation collapses the left of the text though. The idea is for it to remain proportional as it scales down. And then eventually take up the full-width for mobile. –  Apr 17 '20 at 23:05
0

If you just want the mobile version's p element to take up full width, with just a tiny bit of padding to prevent text from touching the edge, change your CSS to this:

.header {
    background-color: #090c1a;
}

.header-inner {
  color: white;
  padding: .5rem;
}

You could also add a media query for the larger version to prevent the text from stretching the entire length of the div if you don't want the p element spread out too far on large screens, like this:

@media(min-width: 768px) {
  .header-inner {
    width: 50%;
  }
}

Play around with the percentage until you get the desired width on full screens.

Nick Kinlen
  • 1,356
  • 4
  • 30
  • 58