Вы можете просто использовать flexbox
для этого.
сначала мы начинаем с flex-direction:column;
, поэтому элементы стекаются, затем с размера экрана 600px
и выше меняются до flex-direction:row-reverse
, что приведет к размещению элементов подряд и в обратном порядке.
.section-3 {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-direction: column;
grid-gap: 2rem;
text-align: center;
}
.grafica {
padding: 1rem;
width: 100%;
margin: 0 auto;
}
.grafica img {
max-width: 100%;
height: auto;
}
@media (min-width: 600px) {
.section-3 {
flex-direction: row-reverse;
}
}
<div class="section-3">
<div class="grafica">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
</div>
<div class="grafica">
<img src="https://picsum.photos/300" />
</div>
</div>
Если вы должны использовать CSS Grid
, тогда вы можете просто указать каждый столбец элементов индивидуально.
.section-3 {
max-width: 1200px;
margin: 0 auto;
display: grid;
grid-gap: 2rem;
text-align: center;
}
.grafica {
padding: 1rem;
width: 100%;
margin: 0 auto;
}
.grafica img {
max-width: 100%;
height: auto;
}
@media (min-width: 600px) {
.section-3 {
grid-template-columns: repeat(2, 1fr);
}
.section-3> .grafica:nth-child(1){
grid-column:2;
}
.section-3>.grafica:nth-child(2){
grid-column:1;
}
}
<div class="section-3">
<div class="grafica">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
</div>
<div class="grafica">
<img src="https://picsum.photos/300" />
</div>
</div>