1

Good day,

I have a little gallery section on a web page where I make use of a css grid. it works perfectly fine on a normal web browser and when i scale it down i have managed to have it adjust as i wish using Media Queries (one image after the other), To my disappointment this didn't work when viewing on a mobile devise.

This is my first web site i have created so i expected issues. but I am now stuck on this one.

I need the images to arrange themselves below each other on a mobile browser. How would I go about this? see below html & css, the webpage is redneckrebellion.co.za if you want to see what I'm talking about or see https://codepen.io/underlight/pen/eyYLBa.

<content class="main-body">
<div class="main-content">
    <div class="portfolio">
        <div class="portfolio-item medium-one">
            <div class="description">
                <h1 class="text">Coffee Table</h1>
                <p class="text">Custom Union Jack Coffee Table</p>
            </div>
        </div>
        <div class="portfolio-item medium-two">
            <div class="description">
                <h1 class="text">Laser Cut Logo</h1>
                <p class="text">Redneck Rebellion Laser Cut Logo</p>
            </div>
        </div>
        <div class="portfolio-item wide-one">
            <div class="description">
                <h1 class="text">Custom Desk</h1>
                <p class="text">Custom Desk Built To Clients Design</p>
            </div>
        </div>
        <div class="portfolio-item tall">
            <div class="description">
                <h1 class="text">Container Cupboard</h1>
                <p class="text">Custom Cupboard Built For Lillimex</p>
            </div>
        </div>
        <div class="portfolio-item wide-two">
            <div class="description">
                <h1 class="text">Custom Shelf</h1>
                <p class="text">Custom Shelf Built For Kids Car Themed Bedroom</p>
            </div>
        </div>
    </div>
</div>

thanks!

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
G. Kitshoff
  • 27
  • 1
  • 8
  • You may want to consider using the [viewport meta tag](https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag). Also see [Configure the Viewport](https://developers.google.com/speed/docs/insights/ConfigureViewport) and [What is the viewport element?](https://responsivedesign.is/develop/responsive-html/viewport-meta-element/) – showdev Dec 12 '17 at 19:26
  • 1
    HA! Thank you for the links. viewport meta tag seemed to do the job! – G. Kitshoff Dec 12 '17 at 19:46
  • Awesome! Glad to hear it – showdev Dec 12 '17 at 20:08
  • Thanks! you are correct. – G. Kitshoff Dec 13 '17 at 08:48

3 Answers3

0

There are many ways of doing this, and, based on your question, I'm assuming that these divs are being displayed horizontally already? Which means that they are using the display property of inline or inline-block, or, using float already. If you want to have something that will be re-usable (like Bootstrap framework), you can do something like this:

@media screen and (max-width: 480px) {
    .medium-one, .medium-two .wide-one .tall .wide-two {
        display:block;
    }
}

Also, I would highly recommend using a library that is already made for something like this, such as Bootstrap

Matt Spinks
  • 6,380
  • 3
  • 28
  • 47
0

The simplest way is to surround your .portfolio-item with a media query like this:

@media(min-width: 500px) {
  .portfolio-item {
     margin: 10px;
     box-shadow: 1;
     display: flex;
     justify-content: center;
     align-items: center;
     border: 5px solid white;
     border-radius: 3%;
  }
}
John
  • 187
  • 1
  • 16
0
The grid is a 12-column fluid grid with a max width of 960px, that shrinks with the browser/device at smaller sizes. The max width can be changed with one line of CSS and all columns will resize accordingly. The syntax is simple and it makes coding responsive much easier. Go ahead, resize the browser.

    <!-- .container is main centered wrapper -->
<div class="container">

  <!-- columns should be the immediate child of a .row -->
  <div class="row">
    <div class="one column">One</div>
    <div class="eleven columns">Eleven</div>
  </div>

  <!-- just use a number and class 'column' or 'columns' -->
  <div class="row">
    <div class="two columns">Two</div>
    <div class="ten columns">Ten</div>
  </div>

    enter code here

  <!-- there are a few shorthand columns widths as well -->
  <div class="row">
    <div class="one-third column">1/3</div>
    <div class="two-thirds column">2/3</div>
  </div>
  <div class="row">
    <div class="one-half column">1/2</div>
    <div class="one-half column">1/2</div>
  </div>

</div>

<!-- Note: columns can be nested, but it's not recommended since Skeleton's grid has %-based gutters, meaning a nested grid results in variable with gutters (which can end up being *really* small on certain browser/device sizes) -->