0

I need to create a responsive Masonry images layout but there are 2 large sections which are going to make it very tricky?

See the attached image:

enter image description here

How can I get something like that but responsive?

Nutz24
  • 59
  • 1
  • 8

2 Answers2

1

You may try to use columns to achieve this.

HTML

<section id="photos">
  <img src="images/image-1.jpg" alt="Some Image">
  <img src="images/image-2.jpg" alt="Another Image">
  ...
</section>

CSS

#photos {
  /* Prevent vertical gaps */
  line-height: 0;
  -webkit-column-count: 3;
  -webkit-column-gap:   10px;
  -moz-column-count:    3;
  -moz-column-gap:      10px;
  column-count:         3;
  column-gap:           10px;  
}

#photos img {
  /* Just in case there are inline attributes */
  width: 100% !important;
  height: auto !important;
}

And some media queries CSS

@media (max-width: 800px) {
  #photos {
  -moz-column-count:    2;
  -webkit-column-count: 2;
  column-count:         2;
 }
}
@media (max-width: 400px) {
  #photos {
  -moz-column-count:    1;
  -webkit-column-count: 1;
  column-count:         1;
 }
}

Here is more info in this article Seamless Responsive Photo Grid

Skif
  • 41
  • 4
0

Consider using a framework like Bootstrap. It's grid system makes responsive, column-based layouts easy to create.

You'll have to mess around a little bit for equal heights though.

Here's a jsFiddle with the basic idea (try resizing the viewport to see how it behaves on lower resolutions):

<div class="container">
    <div class="row">
        <div class="col-md-4">
            <div class="content">a</div>
        </div>
        <div class="col-md-4">
            <div class="content">a</div>
        </div>
        <div class="col-md-4">
            <div class="content">a</div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4">
            <div class="content">a</div>
        </div>
        <div class="col-md-8">
            <div class="row">
                <div class="col-md-12">
                    <div class="content">a</div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="content">a</div>
                </div>
                <div class="col-md-6">
                    <div class="content">a</div>
                </div>
            </div>
        </div>
    </div>
    <div class="row"></div>
</div>
Community
  • 1
  • 1
Adrenaxus
  • 1,593
  • 2
  • 18
  • 34