Images appear unaligned in group on mobile view due to responsiveness

Currently facing two issues: creating a responsive container for images where they stay side by side when the resolution changes. However, on testing with a phone, the images stack vertically instead of horizontally, and one image's width appears distorted.

This is what I have attempted:

HTML

<div class="container-fluid">
    <div class="row">
      <div class="col-sm">
        <img src="brands/Adidas-Logo.png" alt="" id="brand_img_adidas">
      </div>
      <div class="col-sm">
        <img src="brands/Nike_logo.png" alt="" id="brand_img_nike">
      </div>
      <div class="col-sm">
        <img src="brands/the-north-face-logo-png-8.png" alt="" id="brand_img_north">
      </div>
      <div class="col-sm">
        <img src="brands/tommy-hilfiger-logo-png-transparent.png" alt="" id="brand_img_tommy">
      </div>
      <div class="col-sm">
        <img src="brands/zara-logo-0.png" alt="" id="brand_img_zara">
      </div>
    </div>
  </div>

CSS

#brand_img_adidas
{
    width: 150px;
    height: 100px;
    max-width: 100%;
    margin-left: 10px;
}

#brand_img_nike
{
    width: 200px;
    height: 100px;
    margin-left: 20px;
    max-width: 100%;
}

#brand_img_north
{
    width: 150px;
    height: 150px;
    margin-left: 20px;
    max-width: 100%;
}

#brand_img_tommy
{
    width: 150px;
    height: 120px;
    margin-left: 20px;
    max-width: 100%;
    margin-right: 0;
}

#brand_img_zara
{
    width: 150px;
    height: 150px;
    margin-left: 10px;
    margin-right: 0;
    max-width: 100%;
}

Answer №1

Although this example does not utilize Bootstrap, it can serve as a helpful guide for incorporating flexbox into your layout.

To arrange the images side by side, you can apply display: flex to the parent container.

By default, the child elements will align in a row due to the flex-direction: row setting.

To handle overflow, consider using the flex-wrap: wrap property which moves items to the next row if necessary.

For further insights on flexbox, visit the link provided here

.row {
  display: flex;
  flex-wrap: wrap;
}

.row .col {
  margin-right: 5px;
}
<div class="row">
  <div class="col">
    <img src="https://via.placeholder.com/150" alt="" id="brand_img_adidas">
  </div>
  <div class="col">
    <img src="https://via.placeholder.com/150" alt="" id="brand_img_2">
  </div>
  <div class="col">
    <img src="https://via.placeholder.com/150" alt="" id="brand_img_3">
  </div>
  <div class="col">
    <img src="https://via.placeholder.com/150" alt="" id="brand_img_4">
  </div>
  <div class="col">
    <img src="https://via.placeholder.com/150" alt="" id="brand_img_5">
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Reopen a Kendo UI dialog

Currently, I am utilizing Kendo UI, and my goal is to display a modal dialog when a button is clicked. The issue I am facing is that it works perfectly the first time around. However, upon closing the dialog and attempting to reopen it by clicking the butt ...

Having difficulty recreating the arrow feature in the bootstrap sidebar

I am currently working on creating the fourth sidebar (from the left) using the templates provided in Bootstrap 5 examples. Everything seems to be falling into place except for one issue - I can't seem to get the arrow to rotate when aria-expanded=tr ...

Effective ways to enable users to upload files in a React Native app

Being in the process of developing a react native app, I am faced with the challenge of allowing users to easily upload files from their mobile devices (pdf, doc, etc). Unfortunately, my search for a suitable native component has proven fruitless. Can anyo ...

Parent menu fails to trigger the opening of child menu upon clicking

I'm struggling to modify a Wordpress theme to enable the child menus to expand when clicking on the parent menus. Is there a way to edit this code to make that functionality work? // Implement expandable menus var expand_link = $('<a class="m ...

At what point is the rendering process of ng-switch completed?

I am currently utilizing ui-router and facing a challenge in instantiating a widget that requires a DOM element specified by its id as a parameter. The specific DOM element is nested within a <div ng-switch>, and I need to ensure the widget construct ...

Tips for ensuring that an absolutely positioned element fills the entire width of the screen while being contained within a fixed-width container

Here is the HTML code snippet: <div id='id1'> <div id='id2'> </div> </div> And now the CSS code snippet: #id1 { width: 300px; height: 200px; margin: 0 auto; background: red; position: relative; ...

Is there anyone available to assist me with troubleshooting a login session that is not functioning properly

I'm a beginner in php and I'm facing an issue with logging in as a different user in a project. After logging out and returning to the browser, the previous user's window keeps opening. Below is the code for index.php: <?php if ( ...

Utilizing the power of JavaScript/JQuery to showcase a compilation of all input values within an HTML form

I'm struggling to showcase all the input values from my HTML form on the final page before hitting the "submit" button. Unfortunately, I am facing a challenge as the values are not appearing on the page as expected. Despite several attempts, the valu ...

fullpage.js: the content exceeds the height limit

I am currently working on customizing the jquery script fullpage.js for a website built on the French CMS "SPIP" (). This script is used to create a one-page website with both horizontal and vertical navigation. However, I have encountered an issue with ...

Adjust the maximum and minimum values on a dual thumb slider

I have implemented a two thumb range slider to define the maximum and minimum values. However, I recently discovered that it is possible for the thumbs to cross over each other - the max value can exceed the min value and vice versa. I am looking for a s ...

Ways to include a right arrow symbol for sub-child items and a downward arrow for child menu options

I have a php form that generates a drop-down menu using php mysql. The current menu is simple, but I would like to enhance it by adding a right arrow for sub-children and a down arrow for child menus using css. Unfortunately, I am unable to modify the css ...

Struggling to generate a div using my JS/jQuery code

Currently working on a post-it web application to improve my skills in JavaScript and jQuery. I've encountered a few errors that have me stumped. Although I'm new to StackOverflow, I often use it as a helpful resource. You can find the code here ...

Utilizing Bootstrap 4 to integrate both collapsible and non-collapsible navigation elements

I am working with a bootstrap nav bar and trying to achieve a design where some menu items are collapsible while others remain visible at all times. Below is the code snippet I am using: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.co ...

Is it possible to align items in flexbox to a specific baseline?

Is it possible to specify a baseline override when utilizing flexbox and trying to use align-items:baseline? I have a flex container that contains various divs such as title, image, body, and description. For these flex items, I want them to be centered ...

Utilize Bootstrap 3 Datepicker version 4 to easily set the date using Moment.js or Date objects

I'm currently utilizing the Within my project, I have a datetime picker labeled as dtpFrom <div class='input-group date ' id='dtpFrom'> <input type='text' class="form-control" /> <span c ...

The Div element on my webpage is not adjusting properly to fit the size of mobile devices

My app was created using Quick flip 2, and I needed to resize it for mobile screens, so I implemented jquery-mobile. Here is the code snippet: <!--css--> <style> .quickFlip, .quickFlip3 { height: 350px; width: 400px; } .quickFlip2 { ...

"What is the best way to prevent a button from being enabled in Angular if a list or array is not

I am incorporating data from my service in the component: ngOnInit() { this._sharedService. getReceiptItem().takeUntil(this.ngUnsubscribe). subscribe(products => this.receiptItems = products); } Is there a way to deactivate a button if there ...

arrange the elements in a specified sequence

I am trying to sort an array in a specific order var customOrder = { "1st Presentation / Meeting": 0, "Follow-On Meetings": 1, "Hold\/Uncategorized": 2, "MGL": 3, "PGL": 4, "BGL": 5, "RGL": 6, "SGL": 7, "Uncategorized Leads": 8, ...

Bars of varying heights (Google Chart)

I have incorporated a Google chart within a mat-grid-tile. In this setup, one column displays a value of 50, while the other showcases a value of 30. These particular values are sourced from myService and are accurate. Although when I hover over the bars i ...

retrieving a data input from HTML and showcasing it on a PHP webpage

Instructions: Create a text field using HTML for users to enter email and password data. When the submit button is clicked, the page specified in the form tag URL will load. In the PHP page that is loaded, display the email entered by the user. What code ...