0

Sorry for the newbie question, but...

Say I have three images in a paragraph/div, displayed as

A B C

in desktop view. If I switch to mobile view, the images do not resize, so they appear as

A B

C

...but my goal is to always keep them on one single line, shrinking the entire line to fit.

Every solution I tried resizes stuff individually instead than as a group, so the result is always the same.

In fact, It would be extremely useful if there was a generic solution I could apply to shortcode outputs too!

Please have mercy on this absolute beginner... Thanks!

Marta
  • 1
  • 1

1 Answers1

0

You could just use Bootstrap, which comes with Flex. https://getbootstrap.com/docs/4.4/utilities/flex/

Here's an example. Most of the example is the starter template from https://getbootstrap.com/docs/4.4/getting-started/introduction/ to which I added the div container with the 3 images.

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  </head>
  <body>
    <div class="container-fluid">
        <div class="d-flex bd-highlight">
            <div class="p-2 flex-grow-1 bd-highlight"><img style="width:100%;" src="https://images.pexels.com/photos/3994840/pexels-photo-3994840.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"/></div>
            <div class="p-2 flex-grow-1 bd-highlight"><img style="width:100%;" src="https://images.pexels.com/photos/3994840/pexels-photo-3994840.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"/></div>
            <div class="p-2 flex-grow-1 bd-highlight"><img style="width:100%;" src="https://images.pexels.com/photos/3994840/pexels-photo-3994840.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"/></div>
        </div>
    </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  </body>
</html>
mprivat
  • 21,582
  • 4
  • 54
  • 64
  • This looks wonderful, but I am working within Divi and I was looking for a more self-contained solution in order not to add stuff to the framework. – Marta Mar 31 '20 at 00:09
  • You could always render the example above and inspect the CSS styles and inspire yourself from it. Just a quick note for next time though, you probably should state all the constraints you're working with to save time. – mprivat Apr 01 '20 at 02:33