R
R
Roman Yakushev2014-04-14 13:10:50
css
Roman Yakushev, 2014-04-14 13:10:50

How to correctly align motley images into a grid?

I'm building a website using this template template . The template is paid, so I'm just spying on how the layout goes there. And the template is adaptive, and I also try to layout adaptively ... but it doesn't always work out.
Here's what I've got so far:
41ca460fa84d48f5becb671e9716c16f.png
As you can see from the screen, the pictures are motley. Those. Some are square, some are vertical and some are horizontal.
What options do I see:
1. Push a div into the background
2. Somehow trick the markup so that the images have a width of 30%, wrap around to the right of each other, and at the same time inside the cell they are centered in height and centered in width . They also had a max-width and a certain max-height (although I don't understand what to specify in it).
Html at the moment:

<div class="vmproduct_gallery productdetails">
  <div class=" width33 floatleft">
    <div class="spacer">
      <a href="/magazin/vspomogatelnoe-oborudovanie/vspomogatelnoe-oborudovanie-i-materialy/silikonovaya-trubka-3-mm-detail.html" title="Силиконовая трубка 3 мм" class="gallery_a">
        <img src="/images/stories/virtuemart/product/resized/119_220x220.png" alt="119" class="gallery_img" />
      </a>					 
    </div>
  </div>
  <div class=" width33 floatleft">
    <div class="spacer">
      <a href="/magazin/vspomogatelnoe-oborudovanie/vspomogatelnoe-oborudovanie-i-materialy/perekhodnik-1-4-kh-1-4-detail.html" title="Переходник 1/4''х 1/4''" class="gallery_a">
        <img src="/images/stories/virtuemart/product/resized/116_220x220.png" alt="116" class="gallery_img" />
      </a>  
    </div>
  </div>
  <!--...-->
</div>

css:
.floatleft {
  float: left;
}
.width33 {
  width: 33%;
}
.gallery_img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 119px;
  margin: 0;
  padding: 0;
  border: none;
  line-height: normal;
  vertical-align: middle;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Kirenkov, 2014-04-14
@CanVas

I support the answer with masonry. BUT if you try to get by with one css, then I would set the height of your block, and the corresponding Line-height size. Well, and text-align: center; This will align your image horizontally and vertically.

S
silentvick, 2014-04-14
@silentvick

jQuery Masonry can solve your problem

J
Jonh Doe, 2014-04-14
@CodeByZen

make the height of all images 100% of the block.
align images in width.
well, I would also add a wide translucent border, so that there is at least some uniformity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question