Tips for aligning Bootstrap 4 cards when the first card header breaks at a word and the second card header does not

Currently, I am working on a personal project using bootstrap 4. However, I've encountered an issue with the class "card" in my gallery section. One card header has 'white-space' set which breaks the word, while the other does not have any 'white-space'. This problem only occurs on a laptop screen, as it works fine on phone screens and desktops.

I've attempted to resolve this by utilizing CSS3 media queries, adjusting margins, but so far, nothing has worked. I searched through StackOverflow for similar problems, but most were related to aligning elements inside the card-body. My goal is to have the card classes aligned properly regardless of word wrapping within them. Unable to provide a direct link to the image, please use the following URL: https://i.sstatic.net/evJWh.jpg

This is how my HTML and CSS are structured:

.whiteSpaceNotAllowed {
    white-space: nowrap;
}

.whiteSpaceAllowed {
    white-space: nowrap;
}

@media screen and (max-width: 768px) {
    .whiteSpaceAllowed {
        white-space: normal;
    }
}

<div class="container-fluid">
<div class="row">
    <div class="col-lg-3">
        <div class="card gallerijCard">
            <div class="card-header GallerijCardHeader">
                <center><p>Ontwerp <span class="whiteSpaceAllowed">& interieur</span></p></center>
               
            </div>
            <div class="card-body">
               
            </div>
        </div>
    </div>
    <div class="col-lg-3">
        <div class="card gallerijCard">
            <div class="card-header GallerijCardHeader">
                <center><p><span class="whiteSpaceNotAllowed">Renovatie</span></p></center>
              
            </div>
            <div class="card-body">
              
            </div>
        </div>
    </div>
</div>

To clarify my objective:

The term 'Ontwerp & interieur' should wrap on a laptop screen, yet both cards must remain aligned horizontally.

Answer №1

// Hey Nicky, here's a simple solution for you - just set a minimum height for all the cards in your gallery. You can adjust the value as needed in the following sections of your code:

<div class="col-lg-3" style='min-height: 300px'>
    <div class="card gallerijCard">
        <div class="card-header GallerijCardHeader">
            <center><p>Ontwerp <span class="whiteSpaceAllowed">& interieur</span></p></center>
            <!-- the span class whiteSpaceAllowed = white-space -> wrapped -->
        </div>
        <div class="card-body">
            <!-- not relevent code -->
        </div>
    </div>
</div>

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

The difference between see-through shades and rgba(0,0,0,0)

What are the primary benefits of using: background-color: rgba(0,0,0,0); over: background-color: transparent; ? ...

Bootstrap does not control the text family, weight, and line height

Currently, I am practicing adding grid layouts using Bootstrap. I have been trying to change the font styling within my project, but unfortunately, none of the changes seem to be taking effect. It's quite frustrating because even though I'm follo ...

Ways to quickly change a class when clicking (without waiting for mouse button release)

Is there a way to instantly change the color of my span element when it's clicked by the user, rather than waiting for the mouse button to be released? This is the CSS code I'm using for the class: span.active{ color:#bdbcae; } I've tri ...

using http to handle a 404 error

This specific function is designed to fetch data under normal circumstances and to return a value of 0 in the event of a 404 error. function retrieveData(url) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); ...

Personalized scrollbar extends beyond the screen

I have been working on creating my own scroll bar, and for the most part, it's functioning well. However, there is one small issue that I'm facing. Whenever I reach the bottom of the page, the handle of the scroll bar disappears underneath the v ...

Learn the process of importing data into an HTML list using Flask

Looking to transfer data from a Python variable to an HTML list? Here's a snippet of HTML code that you can test out: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <title>Panel</title> & ...

Is it possible to emphasize a duration of 25 minutes on an analog clock by utilizing CSS gradients?

I am in the process of incorporating a countdown timer but with an analog clock rather than a digital one. My objective is to emphasize the next 25 minutes as a circle sector that commences from the minute hand on the clock. Here is what I have developed ...

What is preventing the page from scrolling downwards?

Here's a simple question: Why can't I scroll down the page to see the rest of the content in a div that exceeds the length of the window? This has never happened to me before, and I've tried searching for solutions with no luck. I've in ...

Is it possible to conduct HTML-based Selenium tests without an internet connection?

As a newcomer to Selenium, I am currently using the Selenium IDE which has led me to create table structures like the one below: <table cellspacing="1" cellpadding="1" border="1" name="SELENIUM-TEST"> <thead> <tr class="title"> ...

Switching the Vue image on Routerlink's isExactActive feature

Is there a way to display different images based on whether a link is active or not? <router-link to="/"> <img src=" :active = isExactActive ? pic_active.png : pic_inactive.png}}" /> //Something along these lines ...

Prevent users from entering past dates in the date input field

In my project, I have decided to use input type date instead of datepicker. Is there a way to prevent users from selecting back dates in input type date without using datepicker? If you have any suggestions, please let me know. Thank you! ...

Ensure that the logo/header remains fixed at the top of the page at all

Currently, I am facing an issue with keeping my logo/header at the top of the page. I have experimented with CSS properties like position: fixed; z-index: 9999; top: 0; left: 0;, and even tried adjusting the positioning to left: 40%; in an attempt to cente ...

javascript primary inquiry

When a page contains an iframe within an iframe, is it necessary to use parent.parent to access the top frame? Is there a quicker way to navigate to the root of the page instead of using parent.parent; or even parent.parent.parent? ...

Using CSS Zoom / Transform with the iframe Tag in HTML

I'm currently working on embedding a child web page (a plain HTML/PHP file) into a parent web page built on WordPress. The challenge I'm facing is that the parent web page has a width of only 800px, whereas the child web page has a width of appro ...

Animating a character's movement along a bezier curve using HTML5 canvas

Brand new to canvas and animations. What's the reason this (Fiddle) won't work with a sprite while this other one (Fiddle) works seamlessly with a rectangle fill? What element am I overlooking here: ctx.drawImage(img, 10, 10, 13, 50); It does ...

Enhancing the tooltip inner content in Bootstrap with a description:

Can you help me troubleshoot the code below? I am trying to add a description to numbers in my tooltip, but it doesn't seem to be working. Here is the HTML: <input id="contract-length" class="slider slider-step-2 slider-contract-length" ...

Creating an artistic blend by layering p5.js drawings over images in an HTML canvas

I'm having a tough time solving this issue. My goal is to overlay circles on top of an image, ideally using HTML for the image. However, I just can't seem to make it work. let img; function setup() { createCanvas(800,800); img = loadImage(&qu ...

Is it possible to position two fixed divs side by side?

I am currently in the process of building my online portfolio. I am looking to create two fixed divs that will not scroll, each occupying the full height of the page. The content between these two divs should be scrollable while the bars on the left and ri ...

Grouping and styling table data cells within a row: best practices

I am attempting to "group" a collection of cells/<td> elements within a row/<tr> in a <table> in order to apply styles to them. The code below accomplishes what I desire to some extent, but it does have its limitations: /* Issues wit ...

Can someone explain why I still see a broken image icon despite setting the content-type to "image/jpeg"?

Perhaps this question seems trivial, but I would really appreciate a helpful answer. I am familiar with what an http header is and how it can be modified using the header function in PHP. Let's say I have a PHP file named an_image.php with the followi ...