Issue with background-image preventing overflow: hidden and ellipsis from hiding text overflow

I have encountered an issue where I need to hide text with ellipsis, but it isn't working properly when there is a background image in a div before the text. You can see the problem demonstrated here: https://jsfiddle.net/ypbgkrod/6/

.block {
  display: flex;
  margin-top: 0.3em;
}

.summary-content {
  margin-left: 0.2rem;
  width: 100%;
}

.summary-content .description {
  overflow: hidden;
  width: 100%;
}

.ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
<div class="block">
  <div class="thumbnail">
    <div class="thumb" role="img" style="background-image: url(''); height: 73px; width: 130px;"></div>
  </div>
  <div class="summary-content" data-permlink="i-want-more-of-my-life">
    <div class="description">
      <p class="ellipsis">Some random text that is long, long…Some random text that is long, long…Some random text that is long, long…Some random text that is long, long…</p>
    </div>
    <div class='slider'>
      Need this to not overflow hide. Need this to not overflow hide. Need this to not overflow hide.
    </div>
  </div>
</div>

By removing the <div class="thumbnail"> section, the text ellipsis and overflow hidden features work as expected. However, I am still facing issues with the slider not being displayed properly.

In summary, the issue arises from attempting to display a pop-up div with a slider that needs to extend beyond the overflow of the .block div. I tried various solutions such as removing overflow hidden on the .summary-content div, which allows the slider to be fully visible but prevents the ellipsis effect from functioning correctly.

Please refer to the original code snippets provided for a clearer understanding of the problem and attempted solutions. Your assistance in resolving this issue by ensuring the overflow on the ellipsis text is hidden while the slider remains visible would be greatly appreciated.

Thank you!

Answer №1

To resolve the issue, simply include min-width: 0; within the summary-content section of your CSS file. Many thanks for the solution!

.summary-content {
    min-width: 0;
    width: 100%;
}

Answer №2

There are two different div containers with classes .thumbnail and .summary-content. If you set the width to 100% for the summary-content, it would extend beyond the screen width. To fix this issue, I added the following CSS:

.summary-content {
  width: 80%;
}

.block {
  display: flex;
}

.summary-content {
  width: 80%;
}

.summary-content .description {
  overflow: hidden;
  width: 100%;
}

.ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
<div class="block">
  <div class="thumbnail">
    <div class="thumb" role="img" style="background-image: url(''); height: 73px; width: 130px;"></div>
  </div>
  <div class="summary-content" data-permlink="i-want-more-of-my-life">
    <div class="description">
      <p class="ellipsis">Some random long text... Some random long text... Some random long text...</p>
    </div>
    <div class='slider'>
    Need this section not to overflow and hide content. Need this section not to overflow and hide content. Need this section not to overflow and hide content.
    </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

Inspect the variable in JavaScript and then increment it by one every second

I am facing an issue where I need to check a variable. If it's 0, then I need to increment it after 1.5 seconds. If it's 10, then I need to increment it after 0.4 seconds. It's quite complex and the current code implementation is not working ...

Adding additional information to the HTML5 doctype is indeed achievable

Imagine you have a set of IE conditional comment tags in the beginning of your HTML document: <!--[if IE 6]><html class="no-js ie6" lang="en" ><![endif]--> <!--[if IE 7]><html class="no-js ie7" lang="en" ><!--<![endif]- ...

Having issues with the background-image style not displaying correctly in the header of an

Trying to update the "background-image:" of a CSS class upon button click. JQuery: $(function() { $('button').on('click', function() { $('.masthead2').css('background-image', 'url("../img/whitehead ...

Discover all CSS elements with Python Selenium and replace them all

When automating with Python Selenium, I am trying to modify the CSS element style to change the theme color of a page. An example of the page element is shown below: <div style="background: #e7e7e7"> <div style="border-bottom: #e ...

Locate a JQuery element within another JQuery element

Apologies for my poor grasp of English. I am working with HTML and JavaScript. <noindex> <h1>This is h1 in noindex</h1> <div> <h1>This is h1 in noindex and in div</h1> <div> <h1>This is h1 in noindex a ...

Tips for personalizing the color scheme of Material UI Stepper Step?

I need help customizing the disabled Step color for Material UI Steppers. The default colors are Blue for enabled steps and Grey for disabled steps, but I want to change it to a different color as shown in this example: https://i.stack.imgur.com/HGGxp.png ...

I am unable to click on the navigation buttons in my bootstrap template

I've been working on turning a single page Bootstrap template into a multi-page layout. I duplicated the index page and modified them into services, among other things. Although I updated the href to point to these new pages, the navbar buttons are no ...

The collapsed Navbar button is noticeably wider than expected

My Bootstrap 4 Navbar has a "Logout" button on the left side that appears too wide when the navbar is collapsed. How can I adjust the size of the "Logout" button when the navbar is collapsed? <!doctype html> <html lang="de"> <head> ...

CSS - Mysterious Gaps Found in Div Block

Below is the code snippet I am currently working with: html { height: 100%; overflow: hidden; } body { height: 100%; color: #bdc3c7; font-family: Montserrat; background-color: #3E4651; } .nav { ...

Display an HTML tag with JavaScript

My code is in both HTML and TS files. The content stored in the Description variable looks like this: <div>aaaa</div><div>bbbb</div><div>cccc</div> Currently, the output displays as follows: aaaabbbbcccc I want to modi ...

Update the style class of an <img> element using AJAX

My success with AJAX enables PHP execution upon image click. However, I seek a real-time visual representation without page reload. Thus, I aim to alter <img> tag classes on click. Presently, my image tag resembles something like <img title="< ...

Picture transports during change

Is there a way to increase the size of images in a List without causing other images to move when hovered? Currently, when an image is hovered, it increases in size but causes the surrounding images to shift to a new line and I would like to avoid this beh ...

Altering the dimensions of a <div> based on the retrieved data

I am currently retrieving data from an API and displaying certain properties using mapping. I would like to adjust the width of the component based on the value of these properties. <h5> <span className="viewcount" ref={boxSize}> ...

Vue 3 allows for creating multiple cards with unique contents

I received this outcome: Content duplicated but not cloned as a card element Below is the code snippet <script setup> import { ref } from 'vue'; defineProps({ project: String, }); const projectList = ref([ { img: './src/asse ...

Align an image with text using CSS and HTML

I'm having trouble with my CSS and HTML code. I want to align the text to the right of an image in a grid format, but it keeps appearing below the image instead. Here is the code snippet: <html> <head> <style type="text/css"> #conta ...

Is it possible to validate fields without using the form tag and forms.py?

Looking for a way to display specific error messages in HTML with Django, without relying on forms.py or form tags? Wondering if there's a workaround that doesn't involve creating separate forms for each field? Edit Account Function HTML Example ...

Is the ng-style not displaying the background image with the interpolated value?

I have been attempting to update the background image of a div using angular ng-style. Below is the code I am working with: <div class="cover-image" ng-style="{'background-image' : 'url({{data.image}})'}"></div> However, ...

The CSS Accordion seems to be the culprit behind the missing margin or border at the top of my page

Although everything on the page is functioning as desired, there seems to be a missing margin or border that is not causing much trouble. If there is a simple solution or an easy way to identify why this is happening, it would be greatly appreciated. Take ...

I attempted to activate the hover effect on a DOM element using JavaScript, but was unsuccessful. It appears that achieving this is not possible. However, I am curious as to how Chrome is able to

I attempted to activate the hover state of a DOM element using JavaScript, but had no success. It appears that this task is not achievable in the way I initially approached it. I have heard that creating a class with a hover function and then adding or ...

Enhance the appearance of your HTMLEditorField in SilverStripe 3.2 by customizing its CSS style using

I have configured the HtmlEditorConfig for a Content HTMLEditorField. The issue I am facing is that I have to refresh or reload the browser page in order to see my custom CSS settings... Here is my code: HtmlEditorConfig::get('cms')->setOpti ...