r/csshelp • u/_Stretch • Feb 16 '20
CSS Grid & Flexbox: Text expanding max-width instead of going to a new line.
Hi /r/csshelp
I am trying to have 2 sections. One on the left and right.
When I add text to the right hand said (the about) if the text is too long it just expands the grid area instead of going to the line under it.
With the provided codepen, You'll see how the sizes are supposed to look but if you add more text or random characters to the profile <p> tag it just expands the box instead of going to the line under it.
https://codepen.io/stretch_/pen/JjdXrXQ
Thank you for taking the time to read. Any help is appreciated!
10
Upvotes
1
u/weepmeat Feb 21 '20
A couple of things in your
.top-container:First, you can get rid of one of your grid template area rows - they're the same, so two rows of the same set of columns with content filling both doesn't make a difference. So:
grid-template-areas: 'main-showcase main-showcase main-showcase profile' ;instead of:
grid-template-areas: 'main-showcase main-showcase main-showcase profile ''main-showcase main-showcase main-showcase profile';Second, you're missing the grid-template-rows and grid-template-column properties. Try adding:
grid-template-rows: auto;grid-template-columns: repeat(4, 1fr);The template rows auto doesn't really matter too much here since you only have one row. Auto height is fine. The template columns is what you need to fix your problem. The code above defines four equal rows, each 1fr in width (1 fraction) of the total width.
Lastly, you have a max height of 40% - what is that supposed to do? You could mess things up with that.
Anyway, here's a new pen: https://codepen.io/occupant/pen/zYGKgvq