I want to make a responsive grid that takes up the entire width of the screen and without any gaps between each element.
Each elements have to be a square.
I want four elements per line on large screens and one element per line on smartphones.
#work {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: repeat(4, 1fr);
}
.post {
margin: 0;
padding: 0;
width: 480px;
height: 480px;
border: 1px solid red;
}
<div id="work">
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
</div>
Image of the result:
Perfect in large screen but when i reduce the size of my window, elements don't go under each other but still in place and i can scroll in X.
I've tried many solutions i could have found on the internet but no one worked.
Excuse me in advance for any mistakes I may have, I am a beginner in HTML & CSS


@media screen and (max-width: 1000px) { .post { width: 100%; } }