I'm having some trouble disabling/deleting my grid on smaller devices (max-width: 600px) using media queries.
What I want is for the pictures to disappear and the grid to be disabled or turned in to one column, but it does not work how I have it now.
If it isn't possible other tips are appreciated!
.section-am {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 1fr 1fr 7%;
gap: 15px;
max-width: 80%;
margin: 0 auto;
padding: 20px;
overflow: hidden;
}
.about-me1 {
grid-column: 2 / -1;
grid-row: 1 / 2;
margin: 50px;
}
.about-me2 {
grid-column: 1 / 2;
grid-row: 2 / -1;
margin: 50px;
}
.about-me-img1,
.about-me-img2 {
width: 100%;
height: auto;
max-width: 300px;
object-fit: cover;
border-radius: 10px;
margin: 0 auto;
}
.about-me3 {
grid-column: 1/-1;
grid-row-start: 3;
margin: 50px;
text-align: center;
}
.about-me4 {
grid-column: 1/-1;
grid-row-start: 4;
margin: 50px;
text-align: center;
}
.section-am a {
color: #2d545e;
text-decoration: none;
}
.section-am a:hover {
text-decoration: underline;
color: #12343b;
}
@media (max-width: 600px) {
h1 {
padding-top: 100px;
}
.section-am {
grid-template-columns: 1fr;
}
.about-me-img1,
.about-me-img2 {
display: none;
}
}
<section class="section-am">
<p class="about-me1">
Something about me
</p>
<img src="https://picsum.photos/200/300" alt="Picture i took while studying" class="about-me-img1">
<p class="about-me2">
More about me
</p>
<img src="https://picsum.photos/200/300" alt="Picture i took while studying" class="about-me-img2">
<p class="about-me3">Even more</p>
<p class="about-me4">Lastly</p>
</section>
The expected result should be this:
(Sorry for bad quality image, hope you understand my vision)
I think you are almost there. Just need to add few classes in target media query.
.section-am {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 1fr 1fr 7%;
gap: 15px;
max-width: 80%;
margin: 0 auto;
padding: 20px;
overflow: hidden;
}
.about-me1 {
grid-column: 2 / -1;
grid-row: 1 / 2;
margin: 50px;
}
.about-me2 {
grid-column: 1 / 2;
grid-row: 2 / -1;
margin: 50px;
}
.about-me-img1,
.about-me-img2 {
width: 100%;
height: auto;
max-width: 300px;
object-fit: cover;
border-radius: 10px;
margin: 0 auto;
}
.about-me3 {
grid-column: 1/-1;
grid-row-start: 3;
margin: 50px;
text-align: center;
}
.about-me4 {
grid-column: 1/-1;
grid-row-start: 4;
margin: 50px;
text-align: center;
}
.section-am a {
color: #2d545e;
text-decoration: none;
}
.section-am a:hover {
text-decoration: underline;
color: #12343b;
}
@media (max-width: 600px) {
h1 {
padding-top: 100px;
}
.section-am {
grid-template-columns: 1fr;
}
.about-me-img1,
.about-me-img2 {
display: none;
}
.about-me1,
.about-me2,
.about-me3,
.about-me4{
width: 100%;
grid-column: 1;
margin: 15px auto;
}
}
<section class="section-am">
<p class="about-me1">
Something about me
</p>
<img src="https://picsum.photos/200/300" alt="Picture i took while studying" class="about-me-img1">
<p class="about-me2">
More about me
</p>
<img src="https://picsum.photos/200/300" alt="Picture i took while studying" class="about-me-img2">
<p class="about-me3">Even more</p>
<p class="about-me4">Lastly</p>
</section>