Ellipsis are malfunctioning in an absolute position div

In my div, there is an overlay of another absolutely positioned div. However, the text is still overflowing beyond the boundaries of the div.

var mainDiv = ".myclass";
         var mainDivP = ".myclass p";
         $(window).on("load",function(){ multiLine_ellipsis(mainDiv, mainDivP); });
         
         function multiLine_ellipsis(mainDiv, mainDivP) {
          $(mainDivP).each(function(index) {
            var divh = $(mainDiv).height();
            if ($(this).outerHeight() > divh) {
              var returnText = $(this).text().replace(/\W*\s(\S)*$/, '...');
              console.log(returnText);
              $(this).text(returnText);
            }
          });
        }
.myclass {
          color: #FFFFFF;
          font-family: "my-font";
          font-size: 28px;
          padding: 15px;
          height: 100px;
          word-wrap: break-word;
          overflow: hidden;
          position: relative;
        }

        .myOverlay {
          background-image: url("https://dksa1a9fhenpv.cloudfront.net/website/images/overlay.png");
          position: absolute;
          width: 100%;
          z-index: 1;
          bottom: 0;
          height: 100%;
        }
        .outerDiv{
          width:231px;
          height:173px;
          position:relative;
        }
        p{margin:0 0 10px;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <div class="outerDiv">
          <div class="myOverlay">
            <div class="myclass">
              <p>jadu's best Accommodation/ abcd hddndehd lfjhgs</p>
            </div>
          </div>
        </div>

https://i.sstatic.net/ribqI.png

I expected to see ... at the end of the statement but it is not appearing as expected.

Answer №1

By adjusting the font size to 30px in your CSS, you can reveal some of the previously hidden content.

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

How can I trigger an AJAX request when the value in a dropdown menu is changed?

index.php <script type="text/javascript" src="jquery-1.4.2.js"></script> <script type="text/javascript" src="ajax.js"></script> <a href='one.php' class='ajax'>One</a> <a href='two.php' ...

The cloning process is functioning properly, however, I am unable to replicate it via ajax using jQuery

Using jQuery to clone elements is functioning as expected. Here's an example: $("#treeFile" > ul:first > li:first ul > *).clone().appendTo("#dummyTree"); However, I encountered an issue when trying to send the cloned element via a POST Ajax ...

Utilize Ajax and Django to inject context into a template

I'm facing a challenge with displaying data from multiple sources in one view. My plan is to use Ajax, as loading 3 or 4 URLs simultaneously on page load is not feasible. Through the Django Rest Framework, I've managed to fetch the data and see ...

Is it possible to read PDF files using Node.js without relying on external libraries?

When I attempt to extract text from a PDF document using Node.js with the fs.readFile method, the response contains strange characters. fs.readFile(directory + '/' + pdf, 'binary', (err, data) => { if (err) { console.l ...

Mocha: A Unique Perspective on Testing the express.Router Instance

As I was developing a JavaScript controller file, I came across the need to test if my controller instance contains an instance of the express method called Router(). import {assert} from 'chai'; import {UF_Controller} from '../../controlle ...

The functionality of localStorage seems to be dysfunctional in Nuxt js when running in SSR mode

I am encountering an issue while trying to add items to a cart using vuex. The console is showing an error and the products on the page are not displaying correctly. Can someone please guide me on how to resolve this problem? The error in the console is: c ...

What is the best way to position a single element in React using the Grid Component without causing any overlap?

I am struggling with positioning 3 components on my react page: PageHeader, SideMenu & FeatureList (which consists of Display Cards). Here is the code for each component: App.js // App.js code here... PageHeader.js // PageHeader.js code here... SideMenu ...

Assigning a unique identifier to a button that will vary depending on the selected radio input

UPDATED HTML: The circumstances have changed because I am no longer in my office, but the concept remains unchanged. The situation is that on a certain part of a website, users have the option to choose from multiple saved addresses. Each address has a un ...

Bring google map markers to life with animation

Is there a way to create an animation like the one shown in this example? I'd like for the map to highlight the corresponding place when a user clicks or hovers over a location in the list. How can I make this happen? I've tried searching on Go ...

Waiting for the completion of the ScrollIntoView operation using Selenium

Whenever I try to scroll to a specific element and take a screenshot of the page, the driver captures the screenshot before the page has fully scrolled to the element. To address this, I initially included a time sleep in my code: driver.execute_script(&qu ...

Error TS2322: Cannot assign type 'Promise<Hero | undefined>' to type 'Promise<Hero>'

I am currently studying angular4 using the angular tutorial. Here is a function to retrieve a hero from a service: @Injectable() export class HeroService { getHeroes(): Promise<Hero[]> { return new Promise(resolve => { // ...

What is the best way to transmit several data fields to a PHP page using Ajax?

Having an issue where I need to send 2 posts to my author PHP page using AJAX. Here's my original code: $.ajax({ type: "POST", url: "includes/get_competitions.php", data:'sport=<?php echo $_GET['sports']; ?>', success: func ...

Chrome's behavior of reducing the width of inline elements when the content is dynamic

Upon opening the specified URL in Google Chrome, an issue can be observed where on the initial load everything appears fine. However, upon refreshing, the width of the three items at the top (Bedingungen, Preise, and So geht's) collapse. This seems to ...

Refreshing HTML Form upon Submit using JavaScript

I've been searching through various discussions without any luck, but I'm encountering an issue with a form that successfully submits data to a Google Sheet, yet the input fields retain their content after submission. Here is the code: <form ...

Working with conditional statements in AngularJS templates

As a beginner in AngularJs, I am currently developing a Q&A Application that requires rendering questions and their answers in a table format. The questions fall into three different types, each requiring a unique rendering style. Every question is ass ...

What is the method to create a division using jquery along with a selector attribute?

There is a select box included in my code: <select class="horse"> <option value="white" value2="1">white</option> <option value="black" value2="2">black</option> </select> I am looking to create a division that ...

How do you retrieve the font-size value in percentages using jQuery's `css()` method for the element `e`?

When using the $(e).css('font-size')) method, how can I retrieve the font size as it appears (100% in my example)? It currently returns it as 100% of 16px which equals to 16px. jQuery ( function($) { alert($('div').css(&ap ...

Wanting to send a callback function with a parameter to a child component within Polymer

My goal is to devise a versatile Polymer component that triggers a callback function in a parent Polymer component for every occurrence of a data element in the child component. Below is the generic parent structure: <dom-module id="nested-parent"> ...

Having trouble retrieving the routeName as it consistently returns empty

I attempted to extract the routeName from the URL in order to apply a different class to the body's layout when on the /Category page. https://i.stack.imgur.com/J0hsp.png @{string classContent = Request.QueryString["routeName"] != "/ ...

Issues with jQuery slider's fadeIn and fadeOut functionalities are causing unexpected behavior

A question surfaced when implementing a jQuery slider with the help of another user on this website. The issue arose when transitioning the code from the working fiddle to my computer, resulting in a problem that needs addressing. Here is the original fidd ...