-1
I’m having some problems centering my images. I basically wanted to center my images in the center of my page. But if for example I go to another PC with another resolution my site gets all deformed.
I was wondering if anyone could help me.
css:
}
.imagens1{
position: absolute;
top: 220px;
left:310px;
}
.imagens2{
position: absolute;
top: 220px;
left: 550px;
}
.imagens3{
position: absolute;
top: 220px;
left: 790px;
}
.imagens4{
position: absolute;
top: 220px;
left: 1030px;
}
html:
<center>
<div class="w3-content w3-row">
<div class="w3-col s4 imagens1">
<br>
<img class="mySlides1 w3-animate-fading" src="1a.jpg" height="312" width="237">
<img class="mySlides1 w3-animate-fading" src="comida1.png" height="312" width="237">
<img class="mySlides1 w3-animate-fading" src="cozinha1.jpg" height="312" width="237">
</div>
<div class="w3-col s4 imagens2">
<br>
<img class="mySlides2 w3-animate-fading" src="1b.jpg" height="312" width="237">
<img class="mySlides2 w3-animate-fading" src="comida2.png" height="312" width="237">
<img class="mySlides2 w3-animate-fading" src="cozinha2.jpg" height="312" width="237">
</div>
<div class="w3-col s4 imagens3">
<br>
<img class="mySlides3 w3-animate-fading" src="1c.jpg" width="237px" height="312px">
<img class="mySlides3 w3-animate-fading" src="comida3.png" width="237px" height="312px">
<img class="mySlides3 w3-animate-fading" src="cozinha3.png" width="237px" height="312px">
</div>
<div class="w3-col s4 imagens4">
<br>
<img class="mySlides4 w3-animate-fading" src="1d.jpg" width="237px" height="312px" >
<img class="mySlides4 w3-animate-fading" src="comida4.png" width="237px" height="312px">
<img class="mySlides4 w3-animate-fading" src="cozinha4.jpg" width="237px" height="312px">
</div>
</center>
The images are side by side?
– I_like_trains
Yes, they as much as I want. But n are in the center of the page. so much to the right. and if I go to another pc with a different resolution, my site gets all messed up. That’s basically it.
– Lucas Sintra
Use Percentages instead of pixels so it never looks the same on all computers
– I_like_trains
some tips: first, note that the
width
andheight
of all images is the same, so why not remove from thehtml
and for a single class in thecss
. Second, if you useposition: absolute
and fixed measures in positioning, will not work in any resolution, should think in mediates in%
, but try to usemargin: 0 auto
to center horizontally.– Ricardo Pontual