I'm wondering why the columns in my Bootstrap 4 grid don't have uniform height and width

Currently, I am utilizing Bootstrap 4 to create a grid view. However, I have encountered an issue where my columns do not have the same width and their heights are uneven, as evident from the borders. It is mentioned that in Bootstrap 4, columns should inherently have the same height and width, but for some reason, this functionality does not seem to be working in my case. Any assistance on this matter would be greatly appreciated.

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

Below is the code snippet for my grid:

.grid-header {
  background-color: #002f5a;
  color: white;
  height: 70px;
  font-weight: bold;
  font-size: 14pt;
}

.grid-header .col-sm {
  border: 1px solid white;
  padding: 10px 20px 10px 20px;
}

.grid-row {
  border-bottom: 1px solid lightgray;
  border-right: 1px solid lightgray;
  ...

...and so on

Edit: Upon further observation, it appears that this issue only arises when the content within my columns exceeds a certain length, causing them to span multiple lines. Using "text-truncate" is not a viable solution as it would truncate the content unnecessarily.

Answer №1

To ensure each row is of equal length, add a w-100 after every row.

<div class="row">
    <div class="col">col</div>
    <div class="col">col</div>
    <div class="w-100"></div>
    <div class="col">col</div>
    <div class="col">col</div>
</div>

Answer №2

Finally, I found a solution after spending some time on it.

The issue with the width stemmed from the fact that the "emails" were too long and since they were written as one continuous word (without spaces), they could not break properly. To fix this, I made a simple addition to my CSS:

.grid-column-value {
    ...
    word-break: break-word;
    ...
}

To address this problem, you can also consider using options like Bootstrap's .text-truncate class based on your specific requirements.

As for the height-related problems, they occurred because of the inclusion of the .align-items-center class in my row element. By removing this class and making some adjustments in my CSS, I was able to resolve the issue:

.grid-column-value {
    ...
    display: flex;
    align-items: center;
}

.grid-action-column {
    ...
    display: flex;
    align-items: center;
}

This modification essentially provides the same effect as .align-items-center, but focuses directly on the individual columns instead of the entire row.

Now, the grid layout appears as follows: https://i.sstatic.net/90Bq8.png

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

Parsing HTML in PHP from a specified URL

I am a newcomer to PHP and have been trying to parse HTML with it. Despite my efforts, I have not been able to get any examples to work. I attempted using the "SimpleHTMLDom" library but am willing to try anything as long as clear instructions are provided ...

Creating an Image Link within Nivo Slider

I have been trying to figure out how to make an image a link in NivoSlider. I know that I can use captions to create a link, but I want the actual image to be clickable for better accessibility. I found a similar question on StackOverflow, but it was rela ...

What steps do I need to follow in order to incorporate the SQLite database into my application?

My attempt to establish a database connection with my system is met with an issue where, upon calling the function, the application's browser displays this message: The "granjas" table is empty Below is the code snippet for reference: In JavaScript ...

When I click away from the screen, the bottom border of the button disappears

view my fiddle Here is the HTML code snippet I am working with: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> <button> <i class="fa fa-5x fa-motorcycle gobumpr_icon"></ ...

Animate text and div elements with bounce or fade-in effects when they appear on the screen in a React application

Animating the elements of my website is a simple task for me, however I am looking to have them animate only when they are visible on the screen without relying on pixels or offsets. I want the animations to be responsive, even in phone mode, without hav ...

JavaScript's Math.round function does not always produce accurate results

After adding the specified line within the function, the code seems to encounter issues. parseLocalFloatCnt: num = Math.round(num*1.2); Is there a solution available for this problem? Your help is much appreciated. <!DOCTYPE html> <html> < ...

Enhancing jQuery Component while making an Ajax request

When a user clicks a button, I am making an ajax call to send out multiple emails. My goal is to update a "Please wait..." div before and after the call with status updates, as well as report any errors that may occur. However, I have encountered an issue ...

Load information from a JavaScript object when the user clicks dynamically

My challenge involves utilizing a JavaScript object that contains video information such as title and source URL. Within my HTML, I have image placeholders and the goal is to trigger a modal pop-up (using Twitter Bootstrap modal) of the specific video when ...

Ways to include text beneath an image within a column using Bootstrap HTML code

Currently I am working on creating a box using Bootstrap, see the code below: <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <style> .addonscard { width: 100%; ...

The radio button is displaying the text 'on' instead of its designated value

function perform_global(tablecounter) { for (index = 1; index <= 2; ++index) { var dnsname = "dns_name"+index; oRadio = document.getElementsByName(dnsname); alert (" radio ID " + dnsname + " " + index + "length " + oRadio.leng ...

How can I ensure that a button remains fixed at the bottom of a Material UI React Component?

I am currently working on developing a layout for a web application, and I have encountered an issue that I am struggling to resolve. The structure of my grid is as follows: https://i.sstatic.net/TEU2a.png My goal is to ensure that each section inside t ...

What is the quickest way to select CSS elements?

Imagine having a popup element labeled as "popup" with two buttons inside, one positioned on the left and the other on the right side, both having the class "popupbutton". Which CSS rule would be the most optimal in this scenario? #popup a.popupbutton ...

Managing post and session data during PHP form submission

I've encountered an issue with my code structure. What I aim to achieve is: To validate if post values exist, then execute the query and show the results. If post values are not present, check for a session value. If session is available, manipulate ...

I'm puzzled as to why the color isn't showing up on my navigation bar even though I used "padding: 10px !important;"

I really need help with this, I'm quite new to all of this and it's really confusing me. When I remove this line, the color shows up again, but when I add it back in, it just disappears. I've been following a tutorial on YouTube on how to cr ...

Developing a system mode called "night mode"

I've decided to incorporate a dark mode feature into my Wordpress theme. Creating both dark and light modes was a breeze, but now I want to add a third mode that serves as the default for pages. This new mode will automatically switch between dark a ...

Instantly display modal upon website loading

Adding more context to the title, I have a modal that was included in a purchased template and it was originally set to only open when a button is clicked. However, I want the modal to automatically pop up when the page loads. The issue is that the modal ...

Is there a way to activate a click event on a particular child element within a parent element?

When attempting to click on a specific descendant of an element, I located the ancestor using ng-class since it lacked an id. yes = document.querySelectorAll('[ng-controller = "inventoryController"]') Having found the desired ancestor, ...

Is there a way to change this from webkit to moz?

Is there a way to change this code from webkit to moz? background-color: #fff; background-image: -moz-linear-gradient(0deg, transparent 79px, #ABCED4 79px, #ABCED4 81px, transparent 81px), -moz-linear-gradient(#EEE .05em, transparent .05em); ...

Maintain the selected list item after filtering in AngularJS

I am facing an issue with highlighting selected items in a list. I have three first names: Roy, Sam, David displayed in a ul as list items. Initially, I can toggle each li on click just fine. However, after performing a search and returning to the list, th ...

degree of transparency when semi-transparent elements overlap

Imagine you have two <div> elements, one with an opacity of .5 and another overlaying it with the same opacity. What would be the combined opacity of the two? Interestingly, it's not as simple as, .5 × .5 or even, .5 + .5 How can this ...