I’m having some issues making this flex box span 100% of the width of the page.
https://jsfiddle.net/yfhbuwc3/
<html></html>
On the right hand side is whitespace (I have no idea where it’s coming from)
I’ve tried making the width of the container 100% I’ve tried setting it to calc(100% + Xpx) but that doesn’t calculate the spacing right and makes the box on the bottom right cut off the page on smaller screens.
3
Answers
Did you try ?
body {width:100%;}
Your CSS-styles seem to be incomplete. When you are using
flex-basis
, you also should defineflex-grow
and/orflex-shrink
. These properties are defining, how the elements will behave based on their flex-basis.Please try it like this:
Because you’re setting
flex-basis: 48%;
on.top-row
which means each.top-row
will only take48%
of the screen. Since you want them to take the whole screen therefore100/2 = 50%
so setflex-basis
to50%
.And for the
.bottom-row
, you are setting it toflex-basis: 32%;
, therefore100/3 = 33.3333333333%
so setflex-basis
to33.3333333333%
.I recommend learning more about Flexbox in general.