Uneven column heights in Bootstrap design

As part of my exam project, I am designing a website that requires 8 categories of products to be displayed in two rows with equal height columns. However, I have encountered an issue where the columns do not maintain equal height when one column contains more text than the others. I have attempted to address this problem using the following code:

.row [class*="col-"] {
  margin-bottom: -99999px;
  padding-bottom: 99999px;
}

.row {
  overflow: hidden; 
}

I have also tried implementing the following solution:

.equal {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    flex-wrap: wrap;
}
.equal > [class*='col-'] {
    display: flex;
    flex-direction: column;
}

I suspect that there may be an issue with my Bootstrap or some other element causing this discrepancy. Below is the HTML and CSS code I have used:

<div class="container cat-con">
    <div class="row">
        <div class="col-sm-12 col-md-3 px-md-1">
            <div class="content">
                <img src="img/lamp-1.png" >
                <h4 class="card-title">Мебелно Осветление</h4>
            </div>
        </div>
        <div class="col-sm-12 col-md-3 px-md-1">
            <div class="content">
                <img src="stairs.png" >
                <h4 class="card-title">Осветление за стълби</h4>
            </div>
        </div>
        <div class="col-sm-12 col-md-3 px-md-1">
            <div class="content">
                <img src="billboard.png" >
                <h4 class="card-title">Осветление за прозорци, реклами, рафтове и ръбове</h4>
            </div>
        </div>
        <div class="col-sm-12 col-md-3 px-md-1">
            <div class="[content]">
                <img src="[led.png]" >
                 <h4 class="card-title">Основно
                    осветление</h4>
            </div>
        </div>
    </div>
</div>

CSS Styles:

@media (max-width: 992px) {

  }
@media (max-width: 768px) {

}
@media (max-width: 576px) {
  
}



.content {
    text-align: center;
    box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1);
    padding: 30px 5px;
    margin: 6px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.04)), #FFFFFF;
    box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 2px 1px rgba(0, 0, 0, 0.12), 0px 1px 3px rgba(0, 0, 0, 0.2);
    border-radius: 4px;

   
}

.content h4 {
  font-size: 15px;
  margin-top: 15px;
}

.content img {
  width: 6rem;
  margin-top: 10px ;
}

.cat-con {
  margin-bottom: 40px; 
}

Answer №1

Hey, give this code snippet a try to create equal columns:

.section{
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    flex-wrap: wrap; 
    margin-right: -20px;
    margin-left: -20px;
}

.section > [class*='col-'] {
    -ms-flex: 0 0 50%;
    flex: 0 0 50%;
    max-width: 50%;
    position: relative;
    width: 100%;
    padding-right: 20px;
    padding-left: 20px;
}

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

Manipulating CSS for a certain ID that is applied to multiple elements with the help of JQuery

I am attempting to conceal all div elements except the initial one within a specific ID. Despite my efforts to create a custom jQuery script, it does not appear to be functioning. $("div.hero-featureSwap:not(:first)").css({display:none}); Is this scr ...

When padding is added, the size of the containing div will still be affected even with the box-sizing property set to

If you click the Button in the following example, it will add padding to a div called label. If you click it 12 times or more, the size of the containing div named button will start to change size and turn red. I have already applied box-sizing: border-bo ...

Populate div with straight lines running vertically or horizontally

I'm wondering how to create vertical or horizontal lines inside a div. I tried this in the past but lost the code, and searching for "fill div with lines" isn't giving me any relevant results. Here's an image to illustrate what I'm try ...

Problem with animated text in CSS

I am facing an issue with the code below. It is supposed to display "Dedicated People" when scrolling down, however, it is not working in my browser. Could it be that I forgot to include a reference in the head section? The code works fine in CodePen, but ...

I am a newcomer to HTML and I am eager to display the selected options from a <select> element

Can someone help me display the selected licorice flavor, chocolate color, and topping? For example: "Green apple, white, christmas sprinkles." I'm not sure if assigning a numeric value to each option is necessary. I did it on a whim. Please suggest ...

Optimal method for storing website information in a database through Django while utilizing a singular template for all web pages

I'm in the process of creating a website where the majority of the content will have a similar format and layout. I plan to use a single template for each post, with the actual content being stored in a database. The content will consist of HTML para ...

Innovative solutions for seamless transformation of HTML designs into Silverlight 3.0

One of my challenges with clients is getting them on board with web applications. However, I am eager to try something new and explore the potential of Silverlight 3.0. It would be great to see if I can transform some of these applications into fully funct ...

Responsive input form causes floating label to be positioned incorrectly

I have crafted a form using Django, Crispy Forms, and Bootstrap. When the screen width is above 575px, everything looks great with fields of appropriate width and floating labels in their correct position. However, when the screen width drops below 575px, ...

"Transforming your menu into a fully responsive Bootstrap menu: a step-by

Struggling to implement a responsive and animated Bootstrap 5 menu in this Codepen example. Tinkered with a few things, but it always seems to break one way or another. Check out the example here Looking to swap out the current menu with a Bootstrap menu ...

What are the reasons behind the ineffectiveness of !important in CSS?

I am looking to increase the font-size of all text on my website to 200%, you can find some test code in this Fiddle link. If it is a PX issue, why does the code work when I add the style to "<h2>"? <div> <h2 class="test" style="font-size: ...

Tooltip functionality remains inactive despite the presence of JQuery and Bootstrap libraries

While there are similar questions on Stack Overflow here and here, the answers provided did not resolve my issue. In my server's Node/Express/Webpack stack, I have installed Bootstrap 4 alpha 6 and tether.js as a dependency for tooltip functionality ...

What is the correct way to link an image path to my PHP script?

I am currently working on a project as a student where we created a MySQL database named Video_Game_Shop. Our task is to connect this database to a website using PHP and HTML, and display all the games listed in our database on one page. To achieve this, ...

Tips for combining or adding all of the values to a single variable during each iteration in jquery

In my sample json structure, I am using a each loop in jQuery within the success function of an ajax call to retrieve all values and display them in alerts. However, currently I am only receiving one value at a time and need to combine all values into a si ...

Animations are failing to run within a Bootstrap card when using Vue rendering

I have utilized Bootstrap cards to display pricing information in my project. I implemented a collapse feature for half of the card when the screen size is equal to mobile width. While using vanilla Bootstrap, the animation worked seamlessly with the col ...

Vue application experiencing issues with applying Sweet Alert CSS styles

I successfully integrated vue-sweetalert2 into my Vue app (version 2.6). The setup in my main.js file looks like this: import VueSweetalert2 from 'vue-sweetalert2'; Vue.use(VueSweetalert2); In one of my components, I have a basic button with a ...

Elevating the table and row dimensions in Bootstrap

I'm currently working with Bootstrap 3 and I'm having trouble adjusting the height of my table and row. I've tried setting properties like line-height, but nothing seems to work. How can I increase the height? <style> div#descrip ...

Using Bootstrap 4, you can create nested rows that will automatically expand to fill their parent container, which in turn has been set

In my current setup, I have a div with the class "d-flex flex-column" that contains a navbar and a container. Within this container, there is another div with the class "d-flex flex-column" which then contains two rows. I am using flex-grow to make the con ...

What is the best way to toggle the visibility of a div using script with Bootstrap 4's latest display classes?

Upon page load, I have a hidden div using the d-none class from BS4. While I understand how to utilize responsive display classes in BS4, I am encountering an issue with showing or hiding this div via script due to the !important declaration in the CSS. T ...

Utilizing shared components with withStyles and material ui components

I'm currently working on a project using React, TypeScript, and Material UI. Here is the layout I have: <MuiThemeProvider theme={muiTheme}> <My Component/> </MuiThemeProvider> Within my component, the code looks something ...

Changing the 'checked' attribute does not have any impact on how it appears in the browser

I am working on a button group where each button should light up when it is selected. The functionality is not fully working as expected; only one button should be active at a time. https://i.sstatic.net/oB9XG.png let stanceBar = ["long", "short", "out", ...