Responsive design not functioning properly for Bootstrap columns on website

If my display currently looks like this with three equally distanced images at the top and two images at the bottom, how can I achieve that design?

I attempted using Bootstrap by setting the top 3 images as

<div className="col-md-4">
and the bottom 2 as
<div className="col-md-6">
. However, when I resize my screen, the layout gets distorted.

https://i.stack.imgur.com/73ZFb.png

This is the code snippet I am currently using:

<div className="container">
    <div className="row">
        <div className="col-md-4">
            <div className="container5">
                <img style={{ height: "100%", width: "100%" }}
                    src="https://www.w3schools.com/howto/img_avatar.png" />
                    ...
            </div>
        </div>
        
        <div className="col-md-6">
            <div className="container5">
                <img style={{ height: "100%", width: "100%" }}
                    src="https://www.w3schools.com/howto/img_avatar.png" />
                    ...
            </div>
        </div>
   </div>
</div>

and here is my current CSS:

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    font-family: "Poppins", sans-serif;
}

.container5 {
    border-radius: 10px;
    width: 300px;
    height: 400px;
    overflow: hidden;
    background-color: coral;
}
...

Answer №1

  1. Avoid using fixed sizes if you want your layout to be responsive. Using width: 300px; in the css class container5 can cause overlay issues.

  2. If you want a consistent view across different screen sizes, consider using col-sm-6 or similar classes. You can learn more about grid options here. Here's an example:

<div className="col-md-4 col-sm-4 col-4"></div>
  1. When it comes to images, use:
<img src="..." className="img-fluid" />

Answer №2

Consider Trying this Approach

Avoid setting fixed sizes if you want your design to be responsive. For example, in the container5 css class, there is a declaration of width: 300px;

Explore the live demo here Access it now!

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

Is it possible for Express JS to receive incoming requests from external sources and then transmit the retrieved data to the front end of

I am currently developing a React JS frontend for my application, but I have an interesting idea to incorporate an external mobile app that can control certain elements on the screen, such as font styles. To achieve this functionality, I require the web ap ...

Tips for sending props to MUI styled menu for creating specific conditional styling effects

Is it possible to pass props to an already styled Material-UI menu with conditional styling for different minimum widths? The issue I am facing is that the menu's styles are outside of the component receiving the props, so how can I achieve this? c ...

Customizing error messages in react-hook-form-mui: A step-by-step guide

I'm currently diving into the world of react-hook-form-mui library. The documentation provided for this project is quite brief, and I've been struggling to add a validation rule to my form field. Despite trying various methods, none seem to be ef ...

How to emphasize a clicked hyperlink in AngularJS

Here's the HTML code I've been working on: <div id="Navigation" class="md-dialog-full"> <div class="products-options"> <a ng-click='addType("Physical")' href="javascript:void(0);"> < ...

An unforeseen issue occurred while trying to access an indexed element ID

I've recently started learning javascript and jquery, and encountered a problem while working on a script. The script is created by php code that reads lines from a file, processes them, and displays them using arrays. In addition, javascript validat ...

My attempt to use the Redux method for displaying data in my testing environment has not yielded

I've been attempting to showcase the data in a Redux-friendly manner. When the advanced sports search button is clicked, a drawer opens up that should display historical data when the search attributes are selected. For this purpose, I implemented the ...

How come I can click on both radio buttons simultaneously?

How come I can select both radio buttons simultaneously? <form #form="ngForm"> {{ poll.counter1 }} votes <input type="radio" id="{{ poll.choice1 }}" value="{{ poll.choice1 }}" (click)="onChoice1(form)">{{ poll.choice1 }} <br> ...

Even after reaching the bottom of the page, the div for overlay projects continues to scroll

*{ margin: 0; padding: 0; } body{ font-family: helvetica , sans-serif; background-color: #1E1E20; } .parallax-container { /* The image used */ background-image: url("https://i.sstatic.net/BlF.jpg"); animation-name: pixels; animation-durat ...

Surprising Outcome from Applying nextjs with useState and useRef Together

Currently, I am a beginner at learning Next.js and I am working on a small project that includes login functionality and a navigation bar. The code snippet below outlines my approach. Initially, I fetch the user token from my local backend, store it in loc ...

Creating a custom route in Node.js using Express for posting content and adding it to a specific user's page

I am currently working on a node.js express project where I am developing a health app for a trainer to manage his clients. The main functionality of the app includes allowing the trainer to access individual client profiles and view their exercise list by ...

How to retrieve the language of an iOS device using React Native

Currently, I am attempting to retrieve the current locale from iOS devices. During the creation of my project and while using expo, I followed this specific guide. I have experimented with the following code: if (Platform.OS === "android") { langR ...

Encountering an error while configuring webpack with ReactJS: Unexpected token found while

I'm attempting to update the state of all elements within an array in ReactJS, as illustrated below. As a newbie to this application development, it's challenging for me to identify the mistake in my code. closeState(){ this.state.itemList.f ...

Transfer the user data to a component using React Router Dom

Having difficulty transferring the user to a page in React? I've managed to do it with my Navbar component, but I'm stuck trying to replicate it on a regular page. Using user.attributes.x like I did in the Navbar component is throwing an error. ...

The behavior of -webkit-border-radius differs from that of -moz-border-radius

My website is displaying differently on Safari compared to Firefox. I want the CSS to make it look consistent across both browsers. I understand that I could use two div boxes - one for the outline and one for the image. However, I prefer how Firefox only ...

What is the best way to create a mirrored effect for either a card or text using CSS

Can anyone assist me with this CSS issue? When I hover over to view the movie details, the entire word flips along with it. Is there a way to make only the word flip initially, and then have it return to normal when hovered? The HTML code is included belo ...

Compilation of Next.js with Supabase resulted in an error

While working on a project with Next.js and Supabase, everything was going smoothly until I added a table and generated TypeScript Definitions from the PostgreSQL schema using Supabase CLI. The problem arose when I tried running the "npm run build" command ...

Automatically Choosing with Material-UI

** I'm looking for a way to trigger the API call on focus in autocomplete using MUI. I've tried using the selectOnFocus property but it didn't meet my requirements. Is there another property that can help me achieve this? ** <Autocomp ...

There are three checkboxes, one of which is independent of the others and requires jQuery to not consider it part of the collection

Initially, I crafted a query that perfectly met the business requirement until there was a change of heart. Uncheck checkbox if checked with jquery The implementation of this code was flawless $('input[type="checkbox"]').on('change' ...

Tips for Enhancing the Appearance of a List Input Box

While on my hunt for an auto-completing text field, I stumbled across lists. <label>Bad Habit <input list="badhabits" id="habits" name="habit"/> </label> <datalist id="badhabits"> <option value="alcoholics"> <option ...

React.js Material UI Autocomplete Input not functioning as expected

Trying to import Autocomplete exactly from the documentation at https://material-ui.com/components/autocomplete/ results in the following error message being displayed: Failed to compile. ./node_modules/@material-ui/lab/esm/useAutocomplete/useAutocompl ...