I am learning flexbox and my goal is to create a simple flexbox of 3 items that would be responsive to a different device (smartphone, tablets, desktop…). The items should be one on top of the other and together fill all the browser width and height.So basically there should never be a scroll. (to sum up one item at the very top, one at the bottom of the page and the rest takes the left space inbetween).
The width part on desktop and smartphones seems to work. But how to fill the height of the browser and how the font and the boxes adapt to the different height of the different devices is still a mystery for me.
My temporary solution was to increase the margin for smartphone…
What are your thoughts?
Here is what I did:
.container {
display: flex;
flex-wrap: wrap;
width: 100%;
height: 100%;
font-size: 3em;
}
.item {
border: 5px solid red;
margin-bottom: 40px;
}
@media screen and (max-width: 500px) {
.element {
margin-bottom: 70px;
}
}
.one {
flex-basis: 100%;
display: flex;
}
.two {
flex-basis: 80%;
display: flex;
}
@media screen and (max-width: 64em) {
body {
font-size: 80%;
}
}
@media screen and (max-width: 50em) {
body {
font-size: 70%;
}
}
@media screen and (max-width: 30em) {
body {
font-size: 60%;
}
}
.three {
flex-basis: 100%;
}
<div class="container">
<div class="item one">1</div>
<div class="item two">
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</div>
<div class="item three">3</div>
</div>