"The issue of text-overflow ellipsis not functioning persists despite using CSS and jQuery

I am trying to limit the height of each individual topic-container div to 100px by default and display ellipsis at the end to indicate that there is more text. When a specific div is clicked, it should expand to 100% height. However, I am facing an issue where the text adjusts to the width of 100% instead of the height. How can I resolve this?

HTML

 <div class="topics">
   <div class="topic-container"> 
     <img src="http://via.placeholder.com/150x150">
     <div class="name">Full Name</div>
     <div class="title">Title</div>
     <div class="description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget iaculis massa. Mauris sed cursus eros. Quisque tempus eros a diam mollis tincidunt. Ut fermentum diam tortor. Morbi auctor, ipsum nec consequat pharetra, nisl nibh mollis eros, a molestie purus nunc quis augue. Curabitur et erat felis. Nullam eu purus quis dolor consectetur commodo eu a velit. Vivamus at velit.</div>
   </div>

   <div class="topic-container"> 
     <img src="http://via.placeholder.com/150x150">
     <div class="name">Full Name 2</div>
     <div class="title">Title 2</div>
     <div class="description">2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget iaculis massa. Mauris sed cursus eros. Quisque tempus eros a diam mollis tincidunt. Ut fermentum diam tortor. Morbi auctor, ipsum nec consequat pharetra, nisl nibh mollis eros, a molestie purus nunc quis augue. Curabitur et erat felis. Nullam eu purus quis dolor consectetur commodo eu a velit. Vivamus at velit.</div>
   </div>
 </div>

CSS

.topics {
    background-color: white;
    width: 50%;  
    position: relative; 
}
.topic-container {
    float: left;
    margin-left: 1em;
}
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    opacity: 0.5;
    z-index: 50;
}
.description {
  white-space: nowrap;
  width: 100px; 
  height: 100px;
  border: 1px solid red;
  overflow: hidden;
  word-wrap: break-word;
  text-overflow: ellipsis;
}
/*.expand-description {
  width: 150px;
  height: 200px !important;
  position: absolute;
  top: 0;
  background: rgba(0,0,0,0.2);
  color: white;
}*/

JQuery

$('.topics').click(function() {
  $('.description').addClass('expand-description').css('zIndex', '60');
});

Working fiddle: http://jsfiddle.net/qfjk3dmt/

Answer №1

Try removing the white-space: nowrap; property from your CSS class named .description. This might be causing the text to display in a horizontal direction.

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

Leverage the power of jQuery to fetch data from a PHP script connected to a MySQL database

It might be a bit confusing, so let me clarify. I'm working on a form where users input a ticket and it gets assigned to a technician based on the service they offer. I have 3 text fields: username, email, and description of the problem. The next fie ...

html form submission error - please refresh

After submitting a form on my page, I keep encountering an error every time I try to refresh the page. I've attempted several solutions that I came across online, but none of them have resolved the issue as I continue to face this error on different ...

Can Bootstrap CSS take precedence over a theme's styling?

After working with various WordPress theme templates, I am now ready to take on the challenge of creating my own custom themes. One aspect I would like to incorporate is utilizing Bootstrap to ensure my website is responsive. However, I have some questions ...

Adjusting the Number of Months Displayed on a jQuery Datepicker in Real Time

Seeking an answer that couldn't be found elsewhere, I pose this question. If there is an existing solution, please direct me to it. Incorporated in my project is a jQuery Datepicker with the parameter numberOfMonths set to 2. I am encountering an is ...

Using Jquery to remove a row and replace it with a new row containing updated values

As I work on adding new rows to a table using jQuery, I encounter an issue. While I am able to remove rows and reset row numbers and IDs successfully, adding new rows with correct values poses a challenge. The deleted rows with IDs 3, 4, and 5 are replaced ...

Tips for creating a hidden tab that only appears when hovered over

When hovering over the link tag .cat-link a.navlink, each subcategory tab .subcategories div is displayed. However, I would like to hide all tabs initially and have them appear only when hovered over with the mouse. Once the mouse is removed, I want the t ...

Guide to dynamically setting a CSS class property in HTML

Is there a way to dynamically set the value of a property for a CSS class without relying on a compiler or javascript? :root { --color-0 : red; --color-1 : blue; --color-3 : yellow; } .bg-color-[*] { background-color: var(--color-[*]); } I am looking ...

Overlaying Text on Images with Hover Effect - Mobile-friendly Design

I wanted to add an overlay with text to my images using this amazing tutorial I found: http://codepen.io/pdelsignore/pen/uqenH Although it worked perfectly, I faced an issue due to having a responsive website. When trying to use a % as the width / height ...

Having difficulty adjusting images and divs with proportional percentages

Seeking to recreate the familiar experience of using a laptop, specifically on Windows Vista, with constrained proportions. The goal is for the laptop image to scale based on screen size and for all elements inside #Screen to adjust accordingly in relation ...

Bootstrap slider with fading in and out effects

I am attempting to create a bootstrap slider that fades in and out when transitioning between slides, similar to the effect demonstrated in this template.. I am using Visual Studio 2010 with ASP.NET. The issue I'm facing is that when the image change ...

When HTML/jQuery is unable to retrieve information from PHP

I'm developing a website that dynamically displays a data table based on the name you click. To start, here is the main page: random.html <body> <a href="#" id="comp1">comp1</a> <a href="#" id="comp2">comp2</a> <a hre ...

Challenges with Adjusting Background Opacity in CSS

My text has a white background with an opacity of .3, but it's affecting the foreground due to CSS repositioning. Even though the HTML is in a different division, I struggle with certain aspects of CSS and would appreciate guidance from those more exp ...

Is it possible to embed a section of code from a different file?

Looking for a solution to streamline the process of updating multiple web pages with identical header and footer content. Currently have 5-10 pages with the same information, making it time-consuming to manually update each one when changes are needed. I ...

How can you toggle the visibility of a div based on detecting a specific class while scrolling?

My webpage features a sticky header that gains an extra .header-scrolled class when users scroll down. I am looking to switch the logo displayed in the header once it has been scrolled. Below is a simplified version of my HTML code: <header class=".he ...

What could be the reason behind three out of four nearly identical ajax requests functioning as posts while the fourth one only operates as a get?

My MVC View consists of four sections, each with its own save button: Alias, Default, Format, and Specials. These buttons are meant to save specific data fields in the view model, rather than the entire form. The JavaScript/jQuery function in the view trig ...

What is the best way to create a layout with two columns containing SVGs and text, ensuring that the text consistently appears to the right of the SVG

My webpage has two columns, each containing an SVG and some text. However, when I resize the window in Google Chrome, the text drops below the SVG before the window width goes below 600px. How can I prevent this from happening while maintaining a constant ...

retrieving data in an array using an ajax request

Having trouble extracting two values from an ajax call. I can't seem to separate the results returned from the call. $.ajax({ type:'POST', url: 'inc/getuser.php?q='+boxnum, success:functi ...

Steps to display a specific div section upon selecting a dropdown option and clicking the submit button using jQuery

I'm having an issue displaying a specific div section when selecting an option from a dropdown menu. I've written the code below, but it doesn't seem to be working. Can anyone please assist me with this? My actual requirement is that I only ...

"An issue with PHP not receiving any data from AJAX POST request

I've been working on creating a login using AJAX. The issue I'm facing is that when the AJAX function posts data to the PHP file, the data is empty when trying to retrieve it in PHP. Here is my AJAX posting code: function validateUser() { var ...

Blur function not performing as anticipated

I am attempting to achieve a blur effect on a dialog pop-up. Currently, I am using the primeng p-dialog component for this purpose. <p-panelMenu [model]="items" [style]="{'width':'300px'}"></p-panelMenu> <p-dialog head ...