I have a full height page, let say the height is 900px. The page has a right sidebar, in the sidebar I have 2 blocks with text + image. I would like to change the height of the blocks dynamically, to prevent the scrolling on the page. What is the best practice for this?
- Should I calculate the sizes using Javascript?
- Maybe with media queries I can achieve this, but it won't be perfect.
Currently I'm using media queries:
.blocks {
height: 200px;
}
.blocks p {
font-size: 12px;
}
.blocks img {
height: 150px;
}
@media screen and (min-height: 700px) {
.blocks {
height: 300px;
}
.blocks p {
font-size: 14px;
}
.blocks img {
height: 250px;
}
}
Unfortunately with media queries it's not the best, but I don't want to use javascript to calculate sizes, I hope there's better solution with only css. Is flexbox good for this?