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

Tips on configuring the path to incorporate Bootstrap CSS, JavaScript, and font files/classes into HTML when the HTML file and Bootstrap files are located in different directories

<!DOCTYPE html> <html> <head> <title>Unique Demo</title> <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen"> </head> <body> <div class="container"> <form ...

Angular and JS do not have the functionality to toggle the split button

I have a question that seems similar to others I've seen, but I haven't found a solution yet. Can someone please review my code? In the component, I have {{$ctrl.init}} and {{$ctrl.people}} assigned. I am sure this assignment is correct because ...

Padding will not completely fill the <li> and <div> elements

Looking to create a sleek menu bar that's 40px tall and fills up 80% of the browser width. The challenge arises when trying to center the text within the menu items. Despite adjusting padding for alignment, there's still a small gap because of & ...

Arranging Divs Inside a Container Div - Dealing with Overflow

I am in the process of developing a website that includes a unique structure that I have not encountered before. This layout involves joining multiple sections within a wrapper. As this is my first time attempting such a layout, I am encountering some chal ...

What is the best approach for customizing nested component styles within a Material-UI theme?

I have designed a mui DataGrid with editable cells. While in edit mode, the input's default padding is set to 0 16px, as shown by the generated style code from mui: .css-jqsvr8-MuiInputBase-root-MuiDataGrid-editInputCell input { padding: 0 16px; h ...

unable to expand navbar in Angular 5 project with Bootstrap 4

I am encountering an issue with my navigation bar in a project that uses Angular5 and Bootstrap4. The navigation bar is supposed to expand when the screen size is small, as indicated by the navbar-expand-sm class in Bootstrap4. However, the navbar remains ...

CSS: Breaking free from the constraints of a Bootstrap-inspired grid layout

Looking to create a template with a background on the left side that extends to the edge of the page within an 8 of 12 bootstrap columns setup. The remaining 4 columns on the right will not have a background. This layout should be responsive, stacking on t ...

Invoke a function within an HTML element inserted using the html() method

Looking for help with a JavaScript function: function toggle_concessions(concessions) { var text = "<table>"+ "<tr><td class='concession-name'>gfhgfbfghfd</td><td class='op-encours&a ...

Navigating Sockets with Navigator in React Native

Every time I encounter the error message undefined is not an object (evaluating this.props.socket.on). In my code, I define the socket in the index.ios.js file as shown below: class Main extends Component { constructor(props) { super(props); ...

Display PHP array information in an HTML table

I am facing an issue with an array that contains a record set generated by the CodeIgniter model. When attempting to display these records in an HTML table using my view, the layout is not rendering correctly. Here is a snippet of my view: <html> & ...

Is it possible to validate the fields on an HTML page that does not include a form tag using jQuery?

Below is a code snippet from my HTML page. Is it possible to validate the two specified text fields using jQuery without using any form tag in my HTML page? <div id="panel1"> <fieldset id="fieldset1"> <legend>Registration Details:</ ...

Detecting file corruption from a form-based web page file upload (using input type="file")

Can file corruption occur during the process of uploading a file through a web form? Specifically, when an input of type "file" is included in a form submission and the file is saved on the server (typically in a designated temporary upload directory). Is ...

Exploring Cypress Component Testing within a NextJS project

Could someone assist me with understanding how to utilize the cypress plugin for nextJS in order to execute Cypress Components Test package.json "devDependencies": { "@cypress/react": "^5.3.4", "@cypress/webp ...

Finding the value of a radio button dynamically created by jQuery

I am having an issue retrieving the value of a radio button that is generated using jQuery. I suspect there may be some problems with event handling. Below is my code: HTML <div id="divOption1"></div> The jQuery script to generate t ...

Utilize the 'document / redirect' API within an express controller function

Here is how I have an API call using document / redirect: This call is made within HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmln ...

Executing Selenium test cases based on HTML tag is a key aspect of automated testing

I need to run my selenium test scenarios based on the value of an HTML tag, for example: <meta name="survey name" content="ABC Car"> The content represents different event types, with a total of 4 possible event types. ...

Is it possible to access the Express req object inside a Next.js app?

Let's say I have a middleware that includes additional data fields in the express.js req object. My goal is to pass these fields into my React components using my Next.js _app.js. How can I access the req object inside the _app.js file? ...

Using dynamic tag names within React JSX can greatly enhance the flexibility and

I'm working on creating a React component for HTML heading tags (h1, h2, h3, etc.), where the heading level is determined by a prop. Here is how I attempted to approach it: <h{this.props.level}>Hello</h{this.props.level}> My expected out ...

Is it possible to pass additional arguments to setState other than prevState and props?

I'm currently facing an issue with my component that involves calling a function called addOption, which is defined on its parent component. This function takes a parameter 'option' from a form field and concatenates it with an array of opti ...

Achieving perfect alignment both horizontally and vertically using CSS3's viewport height of 100%

I'm trying to utilize CSS3's Viewport Height to create a fullscreen section with a height of 100vh. However, I am encountering difficulties in centering elements both horizontally and vertically within the section. My goal is to have an image and ...