Achieving a multiline ellipsis (clamp) across various levels of HTML tags, compatible with popular browsers like IE and Firefox

After conducting extensive research, I finally discovered a reliable method for implementing multiple Line Ellipsis (using JS, as plain CSS is not effective). Despite exploring 100 different Google results and Q/As, this is currently the only solution that actually works on various browsers including Chrome, IE 11, Firefox, etc:

http://jsfiddle.net/Warspawn/9nz3T/

The issue with the above fiddle in my case is that it assumes the text being clamped is within a single HTML tag (text-clamp being the Angular directive responsible for the task):

 <p text-clamp="1">a normally very long text</p>

In my scenario, the text I need to clamp is within an h1 tag and consists of multiple elements:

<h1 text-clamp="1">{{getIntroText()}}
      <span>&nbsp;as&nbsp;
         <span class="highlight">{{getCount()}}</span>
      </span>
      <span>&nbsp;in&nbsp;
          <span class="highlight">{{getAnotherPart()}}</span>
      </span>
</h1>

How can I make the above Angular Directive work with my HTML structure?

This is my second fiddle featuring my h1 tag: http://jsfiddle.net/9nqyLxuf/1/

Thank you in advance,

Answer №1

To show text on hover, simply utilize the HTML title tag and let the AngularJS limitTo directive handle the rest

<h1 title="{{bar}}"> {{summary | limitTo:7}} for <span>{{description | limitTo:4}}</span> within {{content | limitTo:2}}...

Check out this live demo on JSFiddle

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

Tips for modifying a HTML table to switch one column with 60 rows to three columns with 20 rows dynamically

Need assistance with separating a dynamically loaded single-column HTML table of 60 rows into three columns of 20 rows each using jQuery in JSP. For example, starting with the loaded table: test 1 test 2 test 3 test 4 test 5 test 6 test 7 test 8 test 9 t ...

Stylish Dropdown Menu with Regular Buttons

Currently, all buttons have a hovering effect, but I only want one button to behave this way. I need two buttons to immediately redirect to another page upon clicking, without any hover effect. The CSS styling code has been provided below: #wrapper { ...

Guide on transmitting JSON data from an AngularJS client to a backend server

Seeking guidance on creating a form in Angular that can send answers as JSON to a MySQL database connected with Django backend and gcloud. Any recommended projects or helpful documentation for this type of implementation? Currently, accounts are created b ...

Angular version 7.2.1 encounters an ES6 class ReferenceError when attempting to access 'X' before it has been initialized

I have encountered an issue with my TypeScript class: export class Vehicule extends TrackableEntity { vehiculeId: number; constructor() { super(); return super.proxify(this); } } The target for my TypeScript in tsconfig.json is set to es6: ...

What is the best way to eliminate the gap above a block element using CSS?

Currently in the process of designing a website, I am faced with a challenging issue that seems to have me stumped. The structure of my page consists entirely of HTML DIVs, with certain elements nested within their parent DIVs. My main dilemma lies in tryi ...

Issue with electron-vue: Unable to modify Vuex state when using RxJS subscribe

I need help with my code involving two functions in the mutations and two pieces of state const state = { files: [], uploadProgress: 0 } const mutations = { SET_UPLOAD_IMAGE: (state, files) => { state.files = files }, UPLOAD_IMAGE: ( ...

Learning how to effectively incorporate two matSuffix mat-icons into an input field

I'm currently experiencing an issue where I need to add a cancel icon in the same line as the input field. The cancel icon should only be visible after some input has been entered. image description here Here's the code I've been working on ...

What is the best way to effectively adjust the code structure in a Node.JS project?

[Summarized] Focus on the bold parts. Although I am relatively new to Node.JS, I have been able to successfully build some projects. However, I have come across a burning question that has left me frustrated after searching Google for answers without much ...

Tips on recycling JavaScript files for a node.js API

I'm currently using a collection of JS files for a node.js server-side API. Here are the files: CommonHandler.js Lib1.js Lib2.js Lib3.js Now, I want to reuse these JS files within an ASP.NET application. What's the best way to bundle these f ...

What are the necessary components for the package.json file of my npm package in order to easily install it within a different project?

I am currently in the process of creating a compact react component that can be easily implemented into other projects. Here is the content of my package.json file so far: { "name": "my-package", "version": "0.1.1&qu ...

Exploring the capability of utilizing undefined properties within the ng model in Angular

Received a code and noticed that the properties like user.name or user.email are being used in ng-model without being declared in the controller. How is it still functioning? How can we send user information to the controller function using ng-click="upda ...

Step-by-step Guide: Building a Nested Bootstrap Navigation Tabs Component on a Webpage

Within a page, I have integrated nested bootstrap navs components. The issue arises when clicking on "Nested Tab 2," which functions correctly, and then switching to "Nested Tab 1" where the tab content is not displaying properly. I am uncertain if there ...

Transmit the Selected Options from the Checkbox Categories

Here's an intriguing situation for you. I've got a webpage that dynamically generates groups of checkboxes, and their names are unknown until they're created. These groups could be named anything from "type" to "profile", and there's a ...

Pressing a button is a way to select a specific form

I'd like to create a clickable button that can direct users to the form section on the same page. <button type="button" class="btn btn-primary btn-sm"> Go to Form Section </button> ... <form id="form1"> <div class="form-g ...

Style the ul and li elements inside a div using CSS

Is there a way to specifically target the <ul> and <li> elements within a designated <div>, rather than applying styles globally? Here is an example of the HTML structure: <div id="navbar_div"> <ul> <li>< ...

Maven, Protractor, and Selenium WebDriver team up for efficient integration testing

Our team has developed a web application that utilizes Java on the back-end and Angular for the user interface, with Maven serving as the build system. We've been working on setting up automated integration testing with Protractor, but despite extens ...

Designing websites and Creating Visual Content

I have been working in IT for quite some time now, but recently I have started to delve more into web development. My main focus is on HTML 5, CSS 3, JavaScript, jQuery, and responsive design. However, one aspect that I always struggle with is images. I am ...

Ways to manage a post request in Next.js

Attempting to establish a POST route within my api directory with next.js. After sending the data to the route, I am having difficulty parsing the data in order to properly store it in the database. What would be the most effective approach for managing ...

express body parser is altering the date field within the body of a POST request

When a date field is sent in a POST request in the local time zone from the client side and received by the body parser, the date gets changed. The left side shows the client payload and the right side shows what is parsed on the server side: https://exa ...

Unable to invoke requestPointerLock() function within Vue.js component

Incorporating the requestPointerLock() method within a Vue.js component has posed some challenges for me. In the scenario where the pointerShouldLock data property of my component is set to true, I intend for the pointer to be locked during the beforeUpdat ...