Problem:
A container that has three boxes is positioned in the center in desktop view. However, it is not in the center when viewed on a mobile.
Minimal Working Example (MWE):
HTML
<article>
<section class="category cars">Cars</section>
<section class="category food">Food</section>
<section class="category drinks">Drinks</section>
</article>
CSS
/* Reset */
* {
margin: 0;
padding: 0;
}
/* Layout */
article {
display: flex;
justify-content: center;
width: 100%;
}
.category {
height: 50px;
width: 200px;
color: white;
text-align: center;
font-size: 1.5rem;
padding: 1rem;
}
/* Background colors */
.cars {
background-color: crimson;
}
.food {
background-color: lightseagreen;
}
.drinks {
background-color: deepskyblue;
}
/* Mobile view */
@media screen and (max-width: 600px) {
article {
flex-direction: column;
}
}
Current output:
The three boxes are positioned to the left.
Desired output:
The three boxes should center in the middle on a mobile view.