I'm looking to showcase a snippet of my dynamic text in this section, limited to just two lines and ending with three dots, with a "read more" link positioned alongside

I've attempted using the CSS ellipsis property, but it's cutting off the first line. I want to display two lines (or set a max character length if possible). I looked into the 'limit' property in Angular to trim text, but it's not working within this InnerHTML content. Please review my HTML:

<div>
  <p class='ellipsis' [innerHTML]="news.newsText"></p>
  <a href="javascript: void(0)" (click)="readmoreFunc(news)">Read more</a>
</div>

This is how it currently appears on the UI: https://i.sstatic.net/xFEkU.png

Answer №1

.truncate {
   overflow: hidden;
   text-overflow: ellipsis;
   display: -webkit-box;
   -webkit-line-clamp: 2; /* specify the number of lines to display */
   -webkit-box-orient: vertical;
}

This solution seems promising.

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

Having trouble with debugging in Chrome ever since upgrading to Angular 11?

Following the update of my angular 9.1 application to angular 11: While debugging within one of the libraries, Chrome no longer stops at my breakpoints. I am still able to debug other libraries and the app as usual. Within the troubl ...

Compiling in Angular 2 CLI can take up a significant amount of time

Working on a rather large project using Angular 2 along with Angular 2 CLI beta 21, I can't help but be surprised by the significant compilation and updating times. Take a look at the ng serve output - it clocks in at 44.8s. $:ng serve ** NG Live De ...

Navigate to a new page on button click using Row with Tanstack / React-Table and Typescript (2339)

Encountering a linting error when attempting to navigate to a new route by clicking on a table row. The functionality is working but how can I resolve this issue? It's showing an error message stating "The property "id" for type TData does not exist." ...

Error message: Injector Error: R3InjectorError(Standalone[_AppComponent])[_WebService -> _WebService -> _WebService] occurred

Being a student, I must apologize in advance for any mistakes in terminology or gaps in my understanding. I am currently developing an Angular front-end to communicate with my backend API. However, I keep encountering the following error in the web page c ...

What is the best way to adjust the placement of this object so it is anchored to the left side?

https://i.sstatic.net/k8aF1.png I'm struggling to position one of my divs more to the left within a flex container. No matter what I try, changing the class of the div doesn't seem to have any effect. Here's the code snippet: import React f ...

Encountering difficulties with resolving a lazy loaded module during Angular's AOT build

Currently, I am not utilizing the Angular CLI for my Ahead-of-Time (AOT) builds, instead opting for Angular 4.x. A module has been created with the intention of being lazily loaded. Below is a portion of my project structure: - app |----lazyLoadedModule ...

Simplifying parameter types for error handling in app.use callback with Express.js and TypeScript

With some familiarity with TypeScript but a newcomer to Express.js, I aim to develop a generic error handler for my Express.js app built in TypeScript. The code snippet below is functional in JavaScript: // catch 404 and forward to error handler app.use((r ...

Is it possible for me to add a div that consistently hovers above other divs on the page

Beginner in the world of CSS. Currently, I am developing a Safari extension where clicking its toolbar button will display a 'dialog banner' (comprising text and a few buttons) on the web page. This banner, in the form of a div, is dynamically a ...

Building CSS Using TagBuilder in .NET Core

Can you provide guidance on utilizing the Tag Builder CSS Class? I am interested in integrating it into a style class .custom-image { max-width: 100%; max-height: 100%; padding: 0; background-color: white; } TagBuilder image = new TagBuilder("img"); Wh ...

Error encountered in Angular Html2Pdf: Unable to assign the 'adoptedStyleSheets' attribute on 'ShadowRoot' due to DOMException

Looking for assistance in implementing html2pdf with Angular 12 to convert specific parts of an HTML page into a downloadable PDF. ERROR MESSAGE An error occurred while trying to execute the code: index-7a8b7a1c.js:150 Uncaught (in promise) DOMExce ...

Adjusting picture dimensions with percentages in canvas and jquery

I'm currently working on a one-page project that involves a canvas where users can click to add or place images randomly. I have made progress with most of the functionality, but as a beginner in jquery and canvas, I am struggling to set a maximum siz ...

The idiom 'listen' is not recognized within the context of type 'Express'. Try using a different property or method to achieve the desired functionality

Encountering an error in VS Code while working on an Angular 13 app that utilizes Angular Universal for Server Side Rendering. The specific error message is: Property 'listen' does not exist on type 'Express'.ts(2339) This error occurs ...

Error: Unable to access the 'DASH' property as it is undefined

Within my current project, I aim to showcase data related to cryptocurrencies. After making an API call, I successfully obtained a response. The specifications of my environment are as follows: Node: 8.9.5, Express: 4.16.4, Angular CLI: 7.3.6, Typescript ...

Reversing the order of input-group-addon and input in bootstrap on mobile devices

I attempted to adjust the layout of a bootstrap input-group-addon on mobile devices by using two input elements and manipulating their display and visibility properties. From a design standpoint, I achieved the desired result as the input is now positione ...

In the HTML body, create some breathing room on the side

While working on a virtual restaurant menu with bootstrap, I encountered an issue where there was a persistent little space at the right side of my page that remained unfilled. Despite trying various solutions and inspecting elements, I couldn't ident ...

Generate detailed documentation for the functional tests conducted by Intern 4 with automated tools

I need to automatically generate documentation for my Intern 4 functional tests. I attempted using typedoc, which worked well when parsing my object page functions. However, it failed when working with functional test suites like the one below: /** * Thi ...

Error encountered while trying to create a new project using Angular-

After executing ng new onepage, I encountered the following error message after waiting for a few minutes: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec8b9e8d8f898a9980c18a9facddc2dec2df">[email  ...

Browse through different backgrounds while a single background remains still for multiple scroll actions

I am trying to create a specific scrolling effect on my webpage: Upon loading the page, I want a div with background1.png to be displayed. As the user starts scrolling, I want this div to remain fixed for a predetermined amount of scroll movements. Once t ...

Achieving Height Diversity in Floating HTML Divs

I have a unique set of dynamically generated divs inside a container div with different heights. <div id="container"> <div id='d1'>Varying content...</div> <div id='d2'>Varying content...</div> < ...

Compiling TypeScript files from multiple source directories

Having 3 NodeJs applications with the latest versions of Typescript code, each containing an "src" folder with TypeScript code files and a "dist" folder with JavaScript files compiled by Typescript. I am now looking to create a "common" folder outside of ...