Stop the div from expanding because of oversize text in Bootstrap

I have the following HTML source code for a Bootstrap card:

<div 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="{% static 'img url' %}"
                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-3">Text of 100 characters Text of 100 characters Text of 100 
                characters Text of 100 characters Text of 100 characters
                </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">
                <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+)</small>
                            </h6>
                        </span>
                    </div>
                </div>
            </div>
            <div class="card-footer p-3 py-md-2 py-lg-2 mt-xl-5">
                <div class="row align-items-center">
                    <div class="col-6">
                        <button type="button"
                            class="btn btn-sm btn-link btn-icon-label hover-translate-y-n3">
                            <span class="btn-inner--icon btn-cust-icon">
                                <i class="mr-1" data-feather="edit-3"></i>
                            </span>
                            <span class="btn-inner--text">Edit</span>
                        </button>
                    </div>
                    <div class="col-6 text-right">
                        <button type="button"
                            class="btn btn-xs btn-outline-danger btn-icon-label hover-translate-y-n3">
                            <span class="btn-inner--icon">
                                <i data-feather="trash-2"></i>
                            </span>
                            <span class="btn-inner--text">Delete</span>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

The issue I'm encountering is that depending on the length of the text within the card-header class, the corresponding div with the card-footer class moves up or down. Is there a way to keep the card-footer fixed and limit the text size to, let's say, 120 characters?

Edit

Added the following code snippet:

.custom-css {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* number of lines to show */
  -webkit-box-orient: vertical;
}
<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="{% static 'img url' %}" 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-3 custom-css">Text 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 characterscharactersText 100 charactersText 100 charactersText 100 charactersText
          100 charactersText 100 charactersText 100 charactersText 100 characterscharactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 charactersText 100 characters
        </h6>
        <p class="font-size-1">
          Text length medium
        </p>
      </div>
      <div class="card-body p-0 px-0 py-md-0 py-lg-0 py-xl-0">
        <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+ review-uri)</small>
                                                        </h6>
                                                    </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</li>

Answer №1

One approach could be setting a min-height and max-height, along with a min-width and max-width to provide boundaries for its size.

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

Is my page not displaying correctly due to compatibility view?

My client "jordanzad.com" has a website where the main page design appears broken when viewed in compatibility view. Can you help fix this issue? ...

Execute jquery commands after the function has finished

I am trying to implement the code below: $(":file").change(function () { if (this.files && this.files[0]) { console.log(this.files[0]); var reader = new FileReader(); ...

Modify the default background color for the chosen element in the tree structure

Could someone assist me in changing the default background color of a selected element in the tree? Below is the XHTML code: <style type="text/css"> .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state- ...

Struggling to align a div vertically using CSS is causing me some difficulties

Hey there, I'm trying to figure out how to align the "container2" div to the bottom of the "container," but I'm running into some issues. Can anyone lend a hand? HTML <div id="container"> <div id="container2"> ...

When CSS width:auto expands beyond its intended length

I'm experiencing an issue when I set the width to auto, the div expands to full length rather than adjusting to the width of the inner divs. Here is the HTML code: <div class="vidswraper"> <div> <div class="videoimage"> <img src ...

Changing the position of a Bootstrap popover dynamically from top to bottom

Struggling with the bootstrap popover here. I can't seem to change the popover position from top to bottom when it reaches the top of the viewport. I attempted to use placement: 'auto bottom' but unfortunately, it didn't do the trick f ...

What's the best way to ensure an endless supply of copied elements with identical classes to the clipboard?

Here is a snippet of my HTML code: <Div Class='POSTS'> <Div Class='POST'> <Div Class='CONTENT'>Text1</Div> </Div> <Div Class='POST'> <Div Class=&apos ...

Tips for displaying a div briefly before loading the second page

Incorporating a div named ADD, I aim to successfully load a second page within the current one using ajaxload. The challenge lies in displaying a div for 4 seconds before loading the second page. How can this be achieved? Following the wait period, the sec ...

A div element appears without any height if there is an image contained within it

I am facing a challenge with a div[div1] that contains other elements. The elements inside have an absolute positioned image, and both div1 and the elements have a float left property without showing any height. Is there a solution to give div1 a height so ...

Implementing a splash screen upon selecting the second exit option

Check out the code snippet here: https://jsfiddle.net/wust7gdy/ Once the curtain is raised, the exit button will appear. How can I introduce a splash screen after clicking the 2nd exit button? Currently, there is a splash screen that appears after click ...

What causes the entire set of dynamically created cards to collapse when using the toggle collapse button in ngb-bootstrap's Collapse control?

I am currently implementing the ngb-bootstrap collapse feature in my Angular 9 application. Incorporating the ngb-bootstrap collapse functionality within a Bootstrap card, I have multiple cards being generated. Each card is equipped with a collapse button ...

Troubles with implementing child routes in Angular 6

I'm having trouble getting the routing and child routing to work in my simple navigation for an angular 6 app. I've configured everything correctly, but it just doesn't seem to be working. Here is the structure of my app: └───src ...

What is the best way to apply CSS to a single div without affecting the rest of the code?

After importing the following stylesheet: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> I noticed that it was affecting other elements on my webpage, like buttons. Is there a way to instruct m ...

Android: Substituting < p > and < br / > elements

My current situation involves receiving JSON data from a website and displaying it in a TextView. I have successfully achieved this, however, my boss requires the text to be plain with no paragraphs or empty lines. The text is retrieved from the website&a ...

Floating layout featuring a static width and a single element that expands

I am looking to create a layout with the following structure: Prefix - Input(Type: Text, Number,..) - Suffix - Button ul { list-style: none; width: 300px; margin: 0; padding: 0; } li { margin: 0; padding: 0; } table { margi ...

What is the best way to implement two distinct global CSS styles for separate pages in Next.js?

I'm looking to give my website a fresh look by creating two different global CSS styles. Is it possible to use one CSS style for the old pages and another for the new pages? ...

Sending information from a parent component to a nested child component in Vue.js

Currently, I am facing a challenge in passing data from a parent component all the way down to a child of the child component. I have tried using props to achieve this as discussed in this helpful thread Vue JS Pass Data From Parent To Child Of Child Of Ch ...

Impossible to create margins on both the left and right side

Check out this cool pen: http://codepen.io/helloworld/pen/BcjCJ?editors=110 I'm facing an issue where I'm unable to create both left and right margins around my datagrid. Only the left margin seems to be possible. Any suggestions on how I can f ...

Improving the method for adding an element to an HTML document with jQuery

What is the best way to add this element to a specific DIV Class using JQUERY in an optimized manner? The elements are generated dynamically and I want to use .AppendTo to display them inside <div class='parent-list-workorder'>. This is wh ...

Issues with jQuery .on() hover functionality in HTML5 select element not being resolved

I'm currently working on capturing the event triggered when the mouse hovers over a select box, regardless of whether it's collapsed or expanded. My approach involves using .on() in the following manner: $(document).on('hover', "select ...