Adjust each column to match the size of the smallest column

With Bootstrap 4, I've set up a grid where the text in the right column on a phone might make the row taller. To address this issue, I've made the body 375px wide to simulate the scenario. What I want is for the row to maintain the size of the image and then use text-overflow: ellipsis to hide any overflowing text. How can I achieve this?

Here's my CSS and HTML:

.infoHeader {
  text-transform: uppercase;
}

#posterCol {
  max-width: 184px;
}

.movieDBImg {
  border-radius: 4px;
}

body {
  width: 375px;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
  <div class="flex-container" style="padding: 15px;">
    <div class="row">
      <div class="col" id="posterCol"><img class="movieDBImg" style="max-width: 154px;"
          src="https://image.tmdb.org/t/p/w300/cezWGskPY5x7GaglTTRN4Fugfb8.jpg"></div>
      <div class="col">
        <div class="row text-muted infoHeader">Directors</div>
        <div class="row">
          Joss Whedon
        </div>
        <div class="row text-muted infoHeader">Genres</div>
        <div class="row">
          <p class="card-text">
            Science Fiction,
            Action,
            Adventure</p>
        </div>
        <div class="row text-muted infoHeader">Cast</div>
        <div class="row">
          Robert Downey Jr.,
          Chris Evans,
          Mark Ruffalo,
          Chris Hemsworth,
          Scarlett Johansson,
          Jeremy Renner,
          Tom Hiddleston,
          Clark Gregg,
          Cobie Smulders,
          Stellan Skarsgård</div>
      </div>
    </div>
  </div>
</body>

</html>

Answer №1

I have implemented the text-overflow: ellipsis feature for your description on mobile view using media queries. Your CSS and inline styles have been optimized and simplified.

.exp-container img {
    max-width: 130px;
    border-radius: 4px;
}

.text-muted {
    text-transform: uppercase;
}

body {
    width: 375px;
}

@media (max-width: 767px) {
    .exp-content .text {
        width: 170px;
        overflow: hidden;
        display: inline-block;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex">
    <div class="exp-container">
        <img src="https://image.tmdb.org/t/p/w300/cezWGskPY5x7GaglTTRN4Fugfb8.jpg" class="img-fluid">
    </div>
    <div class="exp-content mr-auto ml-3">
        <div class="text-muted">Directors</div>
        <div class="text">Joss Whedon</div>
        <div class="text-muted">Genres</div>
        <div class="text">Science Fiction, Action, Adventure</div>
        <div class="text-muted">Cast</div>
        <div class="text">Robert Downey Jr., Chris Evans, Mark Ruffalo, Chris Hemsworth, Scarlett Johansson, Jeremy Renner, Tom Hiddleston, Clark Gregg, Cobie Smulders, Stellan Skarsgård</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

Achieving a full-width image display in Bootstrap: A guide

I've been struggling to find a solution to stretch an image across a div using CSS and Bootstrap. I attempted to make both the div and parent container fluid, but no matter what I try, there always seems to be some white space on the left and right si ...

Automatically filling text fields in JSP using data population algorithms

Currently working on a project using jsp. The page features two text boxes. When the first text box is selected, a list of countries is retrieved from a MySQL database using jQuery. The task at hand now is: Without utilizing any events (especially button ...

JavaScript Tutorial: Updating the maximum value of a gauge chart

Is there a way to dynamically change both the total and max values in my current code? The maximum value needs to be dynamic based on the filter applied. Here is the code snippet: resource1=[ "//cdn.jsdelivr.net/raphael/2.1.0/raphael-min.js", "//cd ...

Gather information on a weekly basis

I have a question regarding pulling data from the table below in a specific format: On a weekly basis, I need to calculate and display the total amount of money paid by each customer. Essentially, I am looking for a query that can help me track the weekly ...

Pandoc fails to display SVG images when converting HTML to DOCX

I am currently utilizing pandoc for the conversion of a standalone html file (without external dependencies), incorporating all necessary css and js within the html itself. Within this HTML document, there are several svg graphs that have been generated th ...

Creating a drop-down button group on mobile with Bootstrap: step-by-step guide

@media (min-width: 320px) { } @media (min-width: 576px) { } @media (min-width: 768px) { } @media (min-width: 992px) { } @media (min-width: 1200px) { } <div class="container"> <div class="row"> <div class="col-lg-24 col-centere ...

Retrieving the contents of an HTML comment tag using Selenium

I’m having trouble retrieving the text inside an HTML comment tag <!-- sample --> that is located within the head section of an HTML page using python 2.7 along with selenium. <head> <!-- I want to extract this statement --> [... ...

Creating a layout with cards positioned next to each other using Bootstrap

I have been trying to display these 3 cards side-by-side, but they always end up stacked on top of each other. Is there a specific code I need to add to fix this? <div class="col-md-4"> <div class="card rounded-lg" style="width: 17.5rem;"> ...

What could be causing my file input to appear misaligned?

Can anyone assist me with a strange issue I am facing? Despite using inspect element on my file input and it appearing in the correct place, it does not function as expected. To see for yourself, visit oceankarma.co and click on 'Post' at the top ...

Include a floating element within a modal box

I am trying to display some cards within a Bootstrap modal form. Inside the modal, I want the cards to appear in two columns by using the "col-md-5" class. .mycard.col-md-5 card contents However, when I use the "col-md-5" class, it adds a property o ...

Changing a background image url using jQuery by clicking a button

I'm struggling to find a way to use jQuery to add a background image URL to my CSS. Everything I've attempted so far has been unsuccessful. let button = document.querySelector('form button.btn') button.addEventListener('click&ap ...

Display the navigation controls in the CSS Bootstrap Carousel only when hovering over the control section, rather than when hovering over the entire carousel

My carousel displays full page images, but I want the controllers to only appear when the mouse hovers over the specific area they are in, rather than appearing when the mouse is anywhere on the page. .carousel .carousel-control { visibility: hidden; ...

Bootstrap modal displaying custom WordPress Contact Form lacks validation and submission feedback

I have implemented a Custom Contact Form in Bootstrap Modal for my WordPress (v5.5.1) using Bootstrap framework following this tutorial: . <form id="contact-form" action="<?php echo get_site_url(); ?>" method="post"&g ...

Duplicate the image from a specific div to another div, ensuring that only one clone is created

I'm trying to replicate an image in multiple spots within a frame, but I can only manage to get one instead of many. Can someone please tell me what I'm doing wrong? I am creating a map of terrain where I need to clone images from one div to anot ...

Having issues with the input event not triggering when the value is modified using jQuery's val() or JavaScript

When a value of an input field is changed programmatically, the expected input and change events do not trigger. Here's an example scenario: var $input = $('#myinput'); $input.on('input', function() { // Perform this action w ...

Receiving the result as well as encountering undefined initially during AJAX request

I have a dropdown menu, and when a user selects an option, an AJAX call is made to retrieve and display data based on the selected value. If the dropdown value is 2, it triggers the AJAX request. However, I am encountering two issues: https://i.sstatic.n ...

A useful Javascript function to wrap a string in <mark> tags within an HTML document

I have a paragraph that I can edit. I need to highlight certain words in this paragraph based on the JSON response I get from another page. Here's an example of the response: HTML: <p id="area" contenteditable> </p> <button class="bt ...

The background image vanishes in Chrome when scrolling downwards

After setting an image with a resolution of 1980 x 1200 as the background for my web page, I encountered an issue. When scrolling down, around the height of 1200px, the image disappears and is replaced by a white background. This problem only occurs in Chr ...

A clever CSS hack for showing multiple UL lists with LI elements in different columns, based on the width of the webpage

On my HTML game website, I feature multiple UL lists at the bottom of each page: <h2>How to play?</h2> <ul> <li><a href="/en/ws/google">Via Google</a></li> <li><a href="/en/ws/apple ...

Store data collected from a form within a Bootstrap modal into a PHP session variable

My goal is to utilize Bootstrap's modal component to collect user information and save it into a session. The form within the modal is designed for users to input their first name, last name, and email address. Upon clicking submit, this information ...