What I am trying to achieve is to have a cut-off width, let's say 600px
- On below 600px screen width, I want the site to look like this (but with same margins on Third):
- On 600px screen width and above, I want the site to look like this (mad image editing skills, yes. Of course, I don't want the text to be stretched like that.):
I have got some building blocks already, starting with using flexbox and @media (min-width: 600px)
, but I would be open to solutions also done with bootstrap 4, for example.
What would be the best way to achieve this?
Here's what I got so far:
html {
color: white;
font-size: 50px;
}
.parent {
background-color: orchid;
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.child {
margin: 5px;
flex-grow: 1;
flex-shrink: 1;
}
.first {
background-color: blue;
height: 110px;
flex-basis:133px;
flex-grow: 0;
flex-shrink: 1;
}
.second {
background-color: green;
}
.third {
background-color: red;
width:100%;
}
@media (min-width: 600px) {
.parent {
flex-direction: column;
height: 120px;
}
.child {
flex-basis:35px;
flex-grow: 1;
flex-shrink: 0;
}
.first {
flex-grow: 1;
flex-shrink: 0;
width: 133px;
flex-basis:110px !important;
}
.second {
width: auto;
height: 50px;
}
.third {
background-color:darkmagenta;
width: auto;
height: 50px;
}
}
<div class="parent">
<div class="first child">
<span>First</span>
</div>
<div class="second child">
<span>Second</span>
</div>
<div class="third child">
<span>Third</span>
</div>
</div>
It otherwise seems to work, but on large screen size, the "Second" and "Third" divs do not want to fill the full space. With width: auto
on .second
and .third
I get too narrow divs
and with width: 100%;
I get too wide divs: