My Grid is not behaving as expected when resizing below 500px using a media query. I want the columns to stack and center after the resize to make it more mobile-friendly. The current media query successfully changes the background to teal, but the grid does not adjust as desired.
body {
margin: 0;
}
img {
max-width: 100%;
}
ul {
list-style: none;
}
a:link {
text-decoration: none;
}
.section-3 {
background-color: #f1f1f1;
padding-top: .7em;
padding-bottom: 2em;
min-height: 50vh;
margin: 0 auto;
border-top: 2px solid teal;
max-width: 100%;
}
.section-3-body {
text-align: center;
max-width: 100%;
}
.section-3 .title .meet {
color: teal;
border-top: 2px solid teal;
border-bottom: 2px solid teal;
border-radius: 4px;
padding: .7em;
display: inline-block;
}
.section-3 .grid-container {
display: grid;
grid-gap: 2em;
grid-template-columns: repeat(3, 1fr);
margin-top: 15px;
max-width: 100%;
overflow: hidden;
}
.grid-container>div {
border: 2px solid #123;
border-radius: 5px;
background-color: #ffd8a8;
padding: 1em;
}
.grid-container h1 {
size: 12px
}
h3+h3 {
margin: 0;
}
h1+h3 {
margin: 0;
}
.section-3 .footer {
margin-top: 30px;
}
.section-3 .footer .learn-more {
color: teal;
padding: .7em;
border-radius: 14px;
border: 2px solid teal;
font-size: 20px;
font-weight: bold;
}
.section-3 .footer .learn-more:hover {
background-color: teal;
color: white;
}
@media screen and (max-width:500px) {
.grid-container {
display: grid;
grid-template-columns: repeat(1, 1fr);
grid-gap: 1rem;
background-color: teal;
}
}
<section class="section-3">
<div class="section-3-body">
<div class="title">
<h1 class="meet">Testing the Testing</h1>
</div>
<div class="grid-container">
<div class="grid-left column">
<img src="https://unsplash.it/400">
<h1 class="name">Testing Names Name</h1>
<h3 class="testing-2">Testing 2</h3>
<h3 class="testing-3">Testing 3</h3>
<h3 class="testing-4">Testing 4</h3>
</div>
<div class="grid-center column">
<img src="https://unsplash.it/400">
<h1 class="name">Testing Names Name</h1>
<h3 class="testing-2">Testing 2</h3>
<h3 class="testing-3">Testing 3</h3>
<h3 class="testing-4">Testing 4</h3>
</div>
<div class="grid-right column">
<img src="https://unsplash.it/400">
<h1 class="name">Testing Names Name</h1>
<h3 class="testing-2">Testing 2</h3>
<h3 class="testing-3">Testing 3</h3>
<h3 class="testing-4">Testing 4</h3>
</div>
</div>
<div class="footer">
<a href="#learn" class="learn-more">Test the button</a>
</div>
</div>
</section>