e1commerce.com
Ask a question
  • New questions
  • With the answers
  • Unanswered
  1. Home
  2. html - Responsive side by side images

137 votes
2 answers

html - Responsive side by side images

Im trying to create a responsive layout in a shopify theme that looks like: http://postimg.org/image/7r6jo647l/ (http://postimg.org/image/7r6jo647l/). I've tried everything and cannot get the desired result. I'm turning to the brighter minds on reddit for help. Any help at all would be appreciated, i named the image frustrating.jpg which pretty much says it all :-/

I'm not looking for someone to do the grunt work, just point me in the right direction...before i go bald tearing my hair out.


Undefined asked
2022-01-11


962
votes

Answer

Solution:

If your theme needs to accommodate a variable number of images use css to manage this:

A minimal set of display:flex display:table for the image wrapper

A fiddle with flex is at:

https://jsfiddle.net/xma6kbxa/ (https://jsfiddle.net/xma6kbxa/)

.wrap, .wrap *{
 box-sizing:border-box;
}

.wrap{
  display:flex;
  margin-left:-5px;
  margin-right:-5px;
  clear:left;
  width:100%;
  border:1px solid blue;
 }
 .wrap .holder{
   margin:5px;
   }
  .wrap img{
    width:100%;
    height:auto;
  }
 }
<div class="wrap">
<div class="holder"><img src="http://placehold.it/350x150"></div>
<div class="holder"><img src="http://placehold.it/350x150"></div>
<div class="holder"><img src="http://placehold.it/350x150"></div>
<div class="holder"><img src="http://placehold.it/350x150"></div>
</div>

<div class="wrap">
<div class="holder"><img src="http://placehold.it/350x150"></div>
<div class="holder"><img src="http://placehold.it/350x150"></div>
<div class="holder"><img src="http://placehold.it/350x150"></div>
Undefined answered
2022-01-11
Link to answer


113
votes

Answer

Solution:

that is easy with Bootstrap - the following will create 4 adjacent divs for the images - these will stack horizontally in a single row of 4 on medium to large size sceens, two rows of two adjacent images on small screens and will stack vertically on mobile (xs) screens.

//row of 4 adjacent images

<div class="row">
    <div class="col-md-3 col-sm-6">
      <img src="smallImage-1.jpg" alt="Small Image1">
    </div>
    <div class="col-md-3 col-sm-6">
      <img src="smallImage-2.jpg" alt="Small Image2">
    </div>
    <div class="col-md-3 col-sm-6">
      <img src="smallImage-3.jpg" alt="Small Image3">
    </div>
    <div class="col-md-3 col-sm-6">
      <img src="smallImage-4.jpg" alt="Small Image5">
    </div>
</div>
Undefined answered
2022-01-11
Link to answer


Source

Didn't find the answer?

Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Similar questions

Find the answer in similar questions on our website.

476 shopify - Pass variables inside render to outside?
456 rubygems - Solution to ruby permission error in github action
694 html - Images appear next to each other rather than under
818 liquid - How to auto update message on side drawer/Cart in Shopify?
943 reactjs - Run react app in development mode inside shopify theme
619 javascript - Jquery - how to get & consider only 1 URL Parameter and ignore the others?
341 reactjs - RangeSlider component does not work inside Filter's shortcut in Polaris Library
684 html - how to change background image by schema shopify?
640 html - Shopify page keep refreshing after being redirected by javascript code
139 Render as HTML the line_item.properties data who has HTML values in it on Shopify Admin Orders

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.







Latest questions:

360 Triggering Zapier on new Shopify order containing a specific product

857 javascript - Swiper js - How can i change the background color of the selected slide

755 Shopify Webhooks not redirect into Laravel Route

476 How to enable / disable my app that is being managed from theme customization section shopify

355 Shopify List Blog Tags



© 2021

E-mail: infot@e1commerce.com