Ways to automatically resize Bootstrap columns to accommodate overflowing elements

Is there a way to make BootStrap 5 columns expand in size when the content inside of them overflows, rather than letting it collide with other elements?

https://i.sstatic.net/WIn0F.png

The current issue I'm facing is that my columns (purple) allow their content to overflow, causing overlapping with adjacent elements. Ideally, I want the columns to dynamically adjust in size based on their contents.

Here's the HTML structure for rows and columns:

<div class="row">
        <div class="col">
            <h1 class="header">User</h1>
            <div class="card card-large border-0 me-1">
                <div class="card-body shadow">
                    <div class="row row-cols-2">
                        <div class="col" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
                            <i class="fa-solid fa-user-pen" style="font-size: 50px;"></i>
                        </div>
                        <div class="right-column">
                            <a class="header row pt-2">Username: </a>
                            <a class="header row pt-2">Plan: </a>
                            <a class="header row pt-2">Discord: </a>
                            <a class="header row pt-2">Date of registration: </a>
                            <a class="header row pt-2">Used searches: /</a>
                        </div>
                    </div>
                    <div class="mt-2">
                        <a class="btn shadow text-white me-1" style="background-color: #7289da">Link Discord</a>
                        <a class="btn btn-secondary shadow text-white me-1">Change password</a>
                        <a class="btn btn-danger shadow text-white" data-bs-toggle="modal" data-bs-target="#logout">Log out</a>

                        <div class="modal fade" id="logout" data-bs-backdrop="logout" data-bs-keyboard="false" tabindex="-1" aria-hidden="true">
                            <div class="modal-dialog modal-dialog-centered" style=" width: 25rem">
                                <div class="modal-content text-white">
                                <div class="modal-body" style="background-color: #0e0e0e">
                                    <div class="container">
                                        <div class="row justify-content-center">
                                            <div class="col-1" style="text-align: left; margin-left: 15px; margin-top: 16px; width: 50px">
                                                <i class="fa-solid fa-triangle-exclamation" style="font-size: 50px;"></i>
                                            </div>
                                            <div class="col-8 mt-4">
                                                Are you sure you wish to log out?
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer border-0 justify-content-center" style="background-color: #0e0e0e">
                                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                                    <button data-bs-dismiss="modal" type="button" class="btn btn-danger" @click="deleteCookie()">Log out</button>
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

Answer №1

Include col-lg-4 within the row column as shown below:

<div class="row">
  <div class="col-lg-4">
    //your content here
  </div>
  <div class="col-lg-4">
    //your content here
  </div>
  <div class="col-lg-4">
    //your content here
  </div>
</div>

For further details, please check out: https://getbootstrap.com/docs/5.2/layout/columns/#how-they-work

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

jQuery does not support CSS pseudo-code

I'm having trouble with my CSS pseudo-code not being recognized by jQuery. Here is the code I'm using: CSS: h1 { background: red; width: 100px; display: inline-block; } h1:after { content:" | "; background:blue; display ...

tips for resizing bootstrap dropdown menu to fill entire page

The image clearly shows that the zabubi solution network platform has a dropdown menu with the label "no request for collaboration to be accepted" on top. The menu occupies half of the page and does not seem to be responsive. Even when the page is resized, ...

Creating a Javascript countdown timer that does not involve displaying the

I stumbled upon this code on a website, but there's one tweak I'd like to make. Unfortunately, I can't seem to figure it out myself, so I'm reaching out for some help. What I want to achieve is removing the year from the date so that th ...

Having trouble with CSS selectors functioning properly in Rhomobile Studio for Android

I am a beginner in the world of Rhodes and Rhomobile Studio. Coming from a Rails background, I am used to the .css.scss file extensions which allow powerful CSS3 codes to be executed. However, in Rhomobile Studio, these extensions are not recognized. I am ...

Troubleshooting the issue with UI-Router AngularJS controller not functioning properly in a

Trying to grasp the ins and outs of UI-Router in conjunction with Angular has proven to be quite challenging for me. In my setup, there's an index: <body> <div ui-view></div> <!--Location of file holding app--> <scri ...

Creating a dynamic menu layout using CSS

I've experimented with various methods to create a fluid menu, but none have been successful. Currently, I have an interactive menu that sometimes displays 6 items and other times 7 items. When I have 7 items, the menu aligns perfectly across the wid ...

Highlighting of tab CSS is not persistent when switching tabs or clicking elsewhere on the page

Using Bootstrap 4, a navigation tab is created. However, upon loading the page, the home tab is automatically loaded but not highlighted. Clicking on any tab will highlight it correctly, but once clicked anywhere else on the page, the highlight disappears. ...

show additional worth on the console

Just starting out with JavaScript. Trying to display additional values in the console. Uncertain about how to access add-ons. Can anyone help me troubleshoot? Here is my code snippet below: https://jsfiddle.net/6f8upe80/ private sports: any = { ...

In search of a regular expression for identifying any of several classes

In the process of upgrading all my websites, I decided to redesign them so that all URL's default to lower case. This meant changing all image names and paths to lower case as well, which was accomplished using regexes. However, this action inadverten ...

Module not found in Node.js environment (webpack)

I seem to be encountering an issue with loading any modules. Despite reinstalling my operating system, I continue to face the same error when attempting to use any module. I have tried reinstalling node, clearing the cache, and more. To view the code, pl ...

translateZ function fails to function properly on Firefox browser

I've been experimenting with using translateZ to hide a child element called "list" behind the parent element "div2. It works perfectly in Chrome, but unfortunately, it's not working correctly on Firefox. Can anyone provide some guidance or help ...

Achieve a full-height sidebar design similar to Wordpress using flexbox functionality

Working on a web app that features a tools sidebar with a fixed width requirement amidst fluid content. Explored using flexbox to achieve this, but encountered an issue where the main box only takes the height of the viewport instead of the entire site&ap ...

Adding external JSON data to a plain HTML document can be achieved through the process of

I have been experimenting with extracting data from an API in JSON format, but I am struggling to figure out how to convert the JSON tags into HTML elements. You can view a sample of the JSON data here. Does anyone know how to transform this JSON into DI ...

Steps to develop a customized form generator using user-provided data

I have been working on developing a dynamic form that generates different levels of content based on user input. For instance, if the user types in "3" for the number of levels, three sets of questions will be created with similar prompts. Each level will ...

What is the best way to showcase React Components in a inline format?

I'm attempting to place multiple React Components in the same line so that I can scroll through them later. Unfortunately, React and Material UI are not cooperating. The Card Components consist of a standard div element with text and an image inside. ...

Guide to creating a visual representation of an audio stream in HTML5

Is it possible to draw a waveform of audio extracted from a webcam media stream in real-time using HTML5 and JavaScript? I have explored: https://github.com/soundcloud/waveformjs https://github.com/katspaugh/wavesurfer.js However, these solutions appea ...

The functionality for determining whether the value isset as 'Yes' or 'No' is not functioning properly in my PHP form

I'm currently working on creating a combined 'Order Calculator / Order Form' using one php form. The calculator part of the form is functioning perfectly and accurately calculates the total for all 5 order options both on the live page and i ...

Movement occurring outside the boundaries of the element

Whenever I hover over the hyperlink, it extends beyond the text of the link. Check out the jsFiddle demonstration: jsFiddle It seems like it is taking the width of the <div>, causing it to be displayed across the entire <div>. Below is the H ...

use ajax to dynamically append a dropdown menu

Currently working on creating a form that includes a dropdown menu populated with elements from a database. The challenge I'm facing is ensuring that once an element is selected from the dropdown, another one appears dynamically. My goal is to use AJA ...

Setting a fixed width for content in CSS based on the size of the browser screen

I'm a newcomer to CSS and HTML and feeling a bit lost on this issue. My goal is to divide the screen into two halves, with one half taking up 50% of the browser screen width while the other half remains flexible. I want the content in one half to be f ...