Preventing text size in Bootstrap from impacting the position of the next div

I've been grappling with this problem for a few days now. Essentially, what I have is the following code for a horizontal card layout where the image appears on the left and the text on the right.

    .title {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    <div class="row">
        <div class="col-lg-12">
            <ul class="list-unstyled">
                <!-- Products -->
                <li class="card shadow-none card-fluid mb-3 mb-md-5">
                    <div class="row">
                        <div class="col-md-3 col-lg-3 mb-3 mb-sm-0">
                            <img class="img-fluid rounded"
                                src="{% img src %}"
                                alt="Image Description">
                        </div>
                        <div class="col-md-9">
                            <div class="card-header py-md-0 py-lg-0 py-xl-0 pl-0 pr-0">
                                <h6 class="h5 mb-2 title">
                                    Lorem ipsum dolor sit amet, consectetuer
                                    adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum
                                    sociis natoque penatibus et magnis dis parturient montes, nascetur
                                    ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu,
                                    pretium quis, sem. Nulla consequat massa quis enim. Donec pede
                                    justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim
                                    justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam
                                    dictum felis eu pede mollis pretium. Integer tincidunt. Cras
                                    dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend
                                    tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend
                                    ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a,
                                </h6>
                                <p class="font-size-1">
                                    Text of 20 characters.
                                </p>
                            </div>
                            <div class="card-body p-0 px-0 py-md-0 py-lg-0 py-xl-0 body">
                                <div class="row">
                                    <div class="col-8 text-left">
                                        <a class="d-inline-flex align-items-center">
                                            <span class="static-rating static-rating-sm d-block mr-2">
                                                <i class="fas fa-star text-warning"></i>
                                                <i class="fas fa-star text-warning"></i>
                                                <i class="fas fa-star text-warning"></i>
                                                <i class="fas fa-star text-warning"></i>
                                                <i class="fas fa-star-half-alt text-warning"></i>
                                            </span>
                                        </a>
                                        <span class="d-inline-block">
                                            <h6 class="mt-0 mb-2">4.95/5
                                                <small class="text-white-70">(1.5k+ reviews)</small>
                                            </h6>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <!-- End Products -->
            </ul>
        </div>
    </div>

As demonstrated above, the card consists of two divs. One contains the header displaying large text, while the other provides additional information such as reviews.

Nevertheless, the second div with the card-body class gets pushed down when the text within the h6 class extends beyond a certain length but remains unaffected when it's shorter.

To address this issue, I attempted to limit the text to a maximum of two lines using the CSS properties shown above:

Despite these adjustments, the second div continues to be impacted. How can I prevent the second div from being displaced under these circumstances? Any suggestions would be greatly appreciated. Thank you!

Answer №1

give this a shot :

.card-header {
height:100px;
overflow: hidden;
text-overflow: ellipsis; 
}

you can benefit from this tip

white-space: nowrap;

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

Ways to conceal rows and columns of a table at the edges

Suppose you have a table measuring 82x82, but you only want to display the central 80x80 section of the table while still retaining the data in the hidden cells. One solution could be enclosing the table within a div element that hides the unnecessary part ...

Enhance the user experience by adding visual appeal to the first option in the selection form. Make it

Is there a way to change the color of the first option in the selection box to grey, similar to the example above? Additionally, how can I create a clickable icon that will display all options? The current setup is not functioning correctly. <div clas ...

Having trouble accessing the 'checked' property of the checkbox

I've been developing a web application using Vite, JavaScript, jQuery, and Bootstrap. I'm facing an issue where the jQuery .is(':checked') function is not working as expected on one specific page. Despite the checkboxes being checked, t ...

Individualize participants and thwart repetition

I need help separating 3 radio players using HTML code and ensuring they remain distinct entities. What code should I use between them to achieve this? For example, all 3 radio players end up looking like the last one at the bottom if not separated correc ...

How to successfully implement ng-show with Html5's <dialog> tags

It's incredible how simple Html5 dialogs are. It feels like they should have been here 15 years ago! I'm having trouble getting ng-show to work with dialogs. Any tips on how to make it happen? <!DOCTYPE html> <html ng-app="project"> ...

The animation feature of the jQuery toggle method is not functioning as expected

In this HTML snippet, I have a JQUERY script that toggles elements with "red" and "green" classes. The code works but without any animation! I want to toggle them in a "slow" mode. I've tried using the animation method too, but it's not working. ...

What is the best way to add an element to multiple websites while avoiding the inheritance of their styles?

Is there a way to add a select element with my own styling to various websites? Many of them have heavily styled their existing select elements, which do not have any classes. How can I ensure that my customized select does not inherit the styles from the ...

Arranging different API's in a table in ascending order of price

This task might be a bit confusing, but it should have a straightforward solution. I am working with two API links in JSON format to pull data into a table. Currently, all data from API1 is inserted into the table first, followed by data from API2. Both ...

Is there a way to use jQuery to efficiently refresh all values within a table?

Whenever I click the "Update All" button, I want all the CHANTIERS values in each line of the list of SALARIES to be checked and updated according to the value selected in the dropdown list. For example, if I choose the value 1 in the dropdown list and cli ...

Is the CSS :not selector failing to operate as expected?

I have been trying to use the :not selector in my code, but for some reason it's not working. I can't figure out why this is happening, especially since the ul element does have the webmedia-gallery class. Any thoughts on what could be causing th ...

Images displayed on cards using BOOTSTRAP

I'm interested in creating cards with categories such as Men, Women, and Kids. I envision these cards to have a design similar to the ones shown here. My goal is for users to be able to click on one of the cards and be directed to either the Men or W ...

Display partial content in Ruby on Rails 5 using link_to without the need to refresh the view

I want to display a partial when a button is clicked without refreshing the page. This is what I attempted in my exploitation_controller: def show_content respond_to do |format| format.js end end In routes.rb: get '/exploi ...

html carousel not updating in popover

I've been attempting to create a popover with a bootstrap carousel, where the carousel items are dynamically generated and appended from a script. Despite my efforts, I have successfully displayed the carousel but struggle to append the items. I' ...

Transient Flash of a jQuery Dropdown Menu

I'm currently developing a jQuery/CSS dropdown menu for a website, and everything is functioning well except for one issue. When navigating between sub-menu items, the text color of the selected main menu item briefly changes because of the CSS border ...

The resizing effect in jQuery causes a blinking animation

I would like to create a functionality where, when the width of .tabla_gs_gm surpasses the width of .content, .tabla_gs_gm disappears and another div appears in its place. While this is already working, there seems to be a screen flicker between the two d ...

Using HTML: What is the best way to match the width of children elements to the width of the

Is there a way to make a child element on my HTML page fill the entire browser window, even when resizing? I want it to stay enlarged and maintain its size as the browser window is resized after loading. I'm unsure if I need to move this object outsi ...

Unavailability of certain CSS rules

I have integrated a Bootstrap jumbotron as the header for my webpage and have my own custom layout.css file. However, not all the styling rules defined for the .jumbotron class seem to be working. Despite setting margin-bottom: 0px;, it does not reflect in ...

CSS - Issue with table cell height exceeding in Mozilla Firefox and Internet Explorer

Examining the code below <div style="border:solid 5px orange;width:400px;height:400px"> <div style="display:table;border:solid 1px red;width:100%;height:100%"> <div style="display:table-row;border:solid 1px blue"> <div sty ...

Retrieve Image Data by Clicking on Canvas at Precise Coordinates

JS Fiddle Link I'm attempting to implement functionality where a canvas with a linear gradient can be clicked, capturing the image data at that specific point. Additionally, I aim to position a yellow picker relative to the click point on the canvas ...

Tips on resizing images in card groups with bootstrap 4?

Hey there! I've come across an issue with my code that was initially working perfectly. The images I'm using have different resolutions, causing the card images to display in various sizes. Is there a way to implement image scaling to ensure all ...