I am having hard time to make this grid responsive. I have 2 rows and 3 columns with each having picture and text. Pictures are same size. I want to make it responsive, so when it reaches certain width, the columns reposition under each other and font size changes to smaller font. Thx for help!
Picture:
.domov2 {
width: 100%;
padding: 0px 0 50px 0;
background-color: #D5D7D7;
min-height: 450px;
}
.domov22 {
width: 80%;
max-width: 960px;
min-width: 960px;
overflow: hidden;
margin: 0;
margin-right: auto;
margin-left: auto;
min-height: 450px;
}
.grid-container {
position: relative;
column-gap: 10%;
row-gap: 50px;
margin: 50px 0px 0px 0px;
/* top right bot left*/
display: grid;
grid-template-columns: 23% 24% 23%;
grid-template-rows: 300px 300px;
padding: 10px;
text-align: justify;
}
.slika {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 220px;
min-width: 220px;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
<section class="domov2">
<section class="domov22">
<div class="grid-container">
<div>
<div class=slika> <img src="slike/computer.png" height=140 class="center"></div><br> Izdelamo vam vizualno atraktivno, urejeno spletno stran.</div>
<div>
<div class=slika> <img src="slike/presentation.png" height=140 class="center"></div><br> Povečajte svojo prodajo in prepoznavnost s privlačno in urejeno spletno stranjo.</div>
<div>
<div class=slika> <img src="slike/brand.png" height=140 class="center"></div><br> SEO optimizacija. Vašo spletno stran optimiziramo tako, da bo dosegala visoke pozicije na “google” iskalniku.</div>
<div>
<div class=slika> <img src="slike/support.png" height=140 class="center"></div><br> Zastonj vzdrževanje (posodabljanje vtičnikov in varnostno kopiranje) prve tri mesece po izdelavi spletne strani.</div>
<div>
<div class=slika> <img src="slike/consulting.png" height=140 class="center"></div><br> Hitra, prijazna in odzivna podpora uporabnikom.</div>
<div>
<div class=slika> <img src="slike/discussion.png" height=140 class="center"></div><br> Nudimo brezplačno prvo svetovanje na daljavo. </div>
</div>
</section>
</section>
2
Answers
Made you mobile adaptation at your discretion. In the css you can see the added two media queries
@media
. You can set the resizing numbers to your liking. Also, I removed themin-width: 960px
rule in.domov22
because this rule prevented the blocks from being made "rubber". Also, I’ve replaced your grid-template-columns: 23% 24% 23%
ongrid-template-columns: repeat(3, 1fr)
Hope it helped. If you have any questions, please contact.Reference: https://css-tricks.com/auto-sizing-columns-css-grid-auto-fill-vs-auto-fit/
You can auto size your columns without using
@media
queryThis adjusts your columns according to screen size