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

Click on the logo to return to the home page

Logo Link Causing Menu Alignment Issue After setting the logo as a link, the menu unexpectedly shifts to the right. Upon inspecting the menu element, it appears that there is an additional hidden menu link on the left side leading to index.html. Can anyon ...

Ensure that HTML5 form fields are validated dynamically to make them mandatory

I have a form created using Bootstrap that contains several fields. By default, the first and second fields are required. Now, if the third field is filled out, the fourth field becomes mandatory. Similarly, if the fourth field is filled out, the third fi ...

Eliminate the lower boundary of a divisional table

I'm having an issue with displaying images in a div table. Each image has a border at the bottom, which is around 2-5 pixels wide. Unfortunately, as a new user, I am unable to send any images. My main goal is to remove this unwanted border from the ...

What could be the reason for the unexpected occurrence of my CSS rule application?

In my collection of CSS files, I have a specific class defined in the common CSS file: common.css .container-example { display: grid; height: 100%; width: 100%; background-color: black; } .container-example > div { overflow: hidden; } This ...

I am experiencing issues with the rendering of my q-btn elements in Quasar and they are

I recently started using Quasar and encountered an issue with my q-btn component buttons displaying white backgrounds at random, despite having added a background-color in the external stylesheets. Here are some examples of this perplexing problem: The e ...

Tips for creating a responsive iframe without relying on aspect ratio assumptions

Is there a way to create a responsive iframe without relying on a fixed aspect ratio? The width and height of the content are unknown until rendering. Keep in mind, using Javascript is an option. For instance: <div id="iframe-container"> <i ...

Obtain the numerical value of the vertical position of the mouse (

Currently, I am coding a JavaScript game and my objective is to designate a variable specifically for the Y axis of the mouse. I kindly request that the code be kept as simple and straightforward as possible, avoiding unnecessary complexity. That conclud ...

Animate the toggling of classes in jQuery

Here is a code snippet that I came across: $('li input:checked').click(function() { $(this).parent().parent().toggleClass("uncheckedBoxBGColor", 1000); }); This code is functioning correctly when the element is clicked for the first time. I ...

Using array.map() in React does not display elements side by side within a grid container

I'm currently working with React and material-ui in order to achieve my goal of displaying a grid container that is populated by an array from an external JavaScript file. The challenge I am facing is getting the grid to show 3 items per row, as it is ...

Display elements exclusively when the class XY is in an active state using JavaScript

Hello everyone, I'm new to this platform and excited to share my first post. Currently, I find myself facing a major challenge as I navigate through a bootcamp program. I have been working on a website with different sections that require specific fu ...

Technique for Retrieving Hyperlinks from HTML Resulting in Repetitive

I have been working on a web-crawler and encountered an issue while parsing the HTML content to extract links. The method I am using seems to be returning duplicate links, even though the HTML content is correct. Here is the code snippet: public static Ar ...

What is the best way to ensure the width of the div is adjusted to fit the table it contains?

What is the best way to adjust the width of a div containing a potentially wider-than-screen table? Despite setting padding: 10px for the div, the right padding disappears when the table exceeds the screen width. Below is an example code snippet: <div ...

Adjust the positioning of two divs on mobile devices

My website has two main divs, one on the left and one on the right. The left div is styled with the classes: col-md-3 left_side And the right div with: col-md-9 right_side In the CSS file, the left_side and right_side classes only have padding, without a ...

What is the best way to vertically center my footer text?

footer { text-align: center; color: #FFF; position: fixed; bottom: 0px; width: 100%; height: 90px; background-color: #464646; } <footer> &copy; Name </footer> I am looking to center my name within the footer, however, it cu ...

What is the best way to create a button with a dynamic background animation in React?

Looking to design a button with an animated background, possibly in gif or video format. An example of what I have in mind is the DOWNLOAD button on this website's main page: Ideally, I am hoping for a solution using React. ...

What is the method for ensuring text remains within a square while it is being relocated?

Check out this jsfiddle where you can interact with a moving square: http://jsfiddle.net/helpme128/3kwwo53t/2/ <div ng-app="test" ng-controller="testCtrl"> <div id="container"> <div class="shape" ng-draggable='dragOptions& ...

Begin with a Bootstrap non-fluid container and follow with a fluid container

I am currently facing a challenge where I want the lower section of my webpage to be full width within a container-fluid div, while keeping the top part in a traditional container with a set width. Despite my efforts, the following HTML snippet is not ach ...

Sending the value from a for loop through AJAX and populating it into a form field

Currently, I have implemented a piece of JavaScript code that captures user input, sends a request to an endpoint using AJAX, and appends a specific field from the returned results as an option within a datalist. This functionality is working perfectly fin ...

What is the best way to position three DIVs next to each other within another DIV while aligning the last DIV to the right?

I need help formatting a simple list item with three DIVs. The first DIV should be left justified, the second should be able to grow as needed, and the third should be right justified. I currently have them stacked side by side, but can't get the last ...

Modify the hue of the div as soon as a button on a separate webpage is

Looking for assistance with a page called "diagnosticoST" that contains four buttons (btn-institucional, btn-economico, btn-social, btn-natural). These buttons have different background colors until the survey inside them is completed. Once the user comple ...