One way to position the second block in the center of the page is to use a little trick by adding an extra block and then utilizing flexbox with justify-content: space-between;
.
However, for the last requirement, I'm uncertain if there are any alternative solutions that don't involve using Javascript or media queries. In this particular scenario, I've resorted to using @media
as I haven't discovered a better approach yet.
Feel free to experiment with this Codepen.
.wrapper {
display: flex;
justify-content: space-between;
align-items: center;
.box {
min-width: 200px;
padding: 12px;
box-sizing: border-box;
background-color: crimson;
color: white;
text-align: center;
&.box--hide {
background: none;
}
}
}
@media screen and (max-width: 660px) {
.box--hide {
display: none;
}
}
<div class="wrapper">
<div class="box">Block 1</div>
<div class="box">Block 2</div>
<div class="box box--hide"></div>
</div>