When working with Angular, text that exceeds a certain length is not wrapping to the next line as it should, but instead overlapping with other

Can someone please assist with a coding issue I'm experiencing in HTML?

<div class="equipment-utilization-chart" >
<ng-container *ngIf="data.healthRecco1 !== ''" >
      <div class="recommendations"> <p> 1. {{data.healthRecco1}}</p> </div>
      <div class="recommendations"><p> 2. {{data.healthRecco2}}</p></div>
      <div class="recommendations"><p>3. {{data.healthRecco3}}</p></div>
  </ng-container>
</div>

The data in variable data.healthRecco2 is lengthy and due to this, it doesn't word wrap properly on the webpage as it rewrites on the same line.

I have included the relevant code snippet from the .scss file below:

.equipment-utilization-chart {
  left: rem(444);
  width: rem(682);
  height: rem(85);
  line-height: 0;

 .recommendations {
width: auto;
height: auto;
margin-top: 35px;
word-wrap: break-word;  
}

}

If anyone has suggestions on how to resolve this issue and get the text to wrap correctly onto the next line, your assistance would be greatly appreciated.

Answer №1

It seems like the issue you're facing is related to using line-height: 0;. When this property is set to zero, it instructs the browser to place new lines directly on top of previous ones without any spacing in between.

Although there are creative ways to utilize zero line-height for specific purposes, in this case, it appears to be causing the problem you're experiencing.

To help illustrate what's happening, I've created a codepen example that demonstrates the impact of this CSS rule:

https://codepen.io/ojako/pen/rZRvpW

Answer №2

Experiment with word-wrap and white-space properties in CSS, then test the results using the console.

Answer №3

To implement this CSS within your SCSS file, make sure to follow these steps:

 .recommendations {
    width: auto;
    height: auto;
    margin-top: 35px;
    word-wrap: break-word;
  }

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

Move the option from one box to another in jQuery and retain its value

Hey guys, I need some assistance with a jQuery function. The first set of boxes works perfectly with the left and right buttons, but the second set is not functioning properly and doesn't display its price value. I want to fix it so that when I click ...

Utilize PHP's IF/ELSE statements to showcase the outcome

In my problem, I have a sample code. What I aim to achieve is to notify the user if there is no data that matches the input they provided, specifically when searching for "Helloworld". I am considering using an if-else statement for validation to determine ...

I'm struggling to make this background show up in a div

Anyone able to help me figure this out? I can't seem to get the achtergrond_homepage.png as a background in rounded corners. Edit: It seems like the gray color is always on top. Could it be controlled in the JavaScript part? This is the CSS: @ch ...

Measuring the pixel distance of scrolling on a page with overflow hidden

I am trying to implement a functionality where a class is toggled for the body element on a page with hidden overflow and single screen, based on the amount of scroll. However, there is a challenge: the scrolling behavior involves animation rather than act ...

Push Button Unleashes a Cascade of Buttons

After creating a dropdown button, I encountered an issue where replicating it multiple times resulted in all the buttons on the page opening simultaneously. I initially thought that wrapping the button in a class called "dropdown" would prevent this from h ...

Applying a dual background effect with one background repeating from the center using CSS3

I am trying to achieve a unique effect with CSS3 backgrounds. I want the second background image to start repeating from the middle of the screen down, rather than from the top. Below is my CSS code: body { background: url('../img/carbon_fibre.png ...

"How to Develop an Eraser Tool Using EaselJs - Exploring Further Possibilities

Currently, I am working on creating a Bitmap eraser on easelJS. I feel like I've made significant progress towards achieving this goal, but I'm still a bit unsure of the next steps... Here is a demo of my progress so far: http://jsfiddle.net/bor ...

Element appearing on screen but not found in the document structure

While using Selenium for HCI tests, I encountered a situation where Selenium was unable to locate a visible element. After some investigation, it seems that the element is visible but not present in the DOM. I could be wrong, but that’s how it appea ...

Angular Flot Chart Resizing: A Guide to Dynamic Chart S

I have successfully integrated a Flot chart into my HTML using an Angular directive. Here is how it looks: <flot id="placeholder" dataset="dataset" options="options" height="300px" width="100%" style="width:100%;" ng-disabled="graphLoading" ng-class="{ ...

Is it possible to execute an npm command within a docker container?

I am facing an issue while attempting to run my Angular application in development mode within a Docker container. When I use docker-compose build, everything works fine, but when I try to start the container, I encounter the following error: ERROR: for ...

Can an image map be utilized within an <a> element?

I am attempting to implement an image map within an <a> tag. It seems to be functioning correctly in Chrome, but I am encountering issues with it not working in Internet Explorer. Is it acceptable to use an image map in an <a> tag? Below is th ...

What is the best way to apply Angular directives to child components for seamless operation?

If I have an angular component that looks like this... <MyComponent></MyComponent> And within MyComponent, there is a native input field (not through transclusion) ... <MyComponent> <input> </MyComponent> Now, let's ...

Is it detrimental to my search engine ranking if I utilize CSS display:none?

Imagine having valuable content that is initially hidden with CSS, and then using javascript to reveal it only when the user clicks on certain links. Even users without javascript enabled can access this content by following the links to a new page where i ...

After selecting "ok" on the JavaScript alert dialog, the webpage will automatically refresh, causing all information entered into the textboxes to be erased

<?php include "dbconfig.php"; session_start(); ?> <!DOCTYPE html> <html> <head> <title>Log in</title> <link rel="stylesheet" type="text/css" href="styles.css"> <link rel="stylesheet" type="text/css" href="bo ...

Utilize Angular Material to assign the value of a mat-select component based on the FormControlName property

I am using Angular version 7 and have encountered an issue with a form I am creating. The form includes a dropdown select to choose an option, but when the page loads, the pre-defined value is not showing up. This page is specifically designed for editing ...

Transforming JSON data into HTML code

I am looking to transfer a list of songs from a JSON file to specific HTML ids using a jQuery function. In the JSON file, there are five songs, and here are two of them in the same format: { "songs": [ { "title": "Bohemian Rhapsody ...

I'm facing a challenge with getting the 'extend' feature to function correctly while using Flask in Python

As someone who is just starting out in programming, I recently decided to embark on creating a web app using flask, python, and HTML. To start off, I set up three essential files - two HTML files, and one python file. The first HTML file requiring informa ...

Submitting HTML elements from a webpage using PHP

Is there a way to store an entire HTML table as a single record in my database? I would like the following table data to be submitted when I click the submit button: <table> <tr><td>Items</td></tr> </table> Can thi ...

Tips for displaying specific information using Javascript depending on the input value of an HTML form

I am working on an HTML form that includes a dropdown list with four different names to choose from. window.onload = function(){ document.getElementById("submit").onclick = displaySelectedStudent; } function displaySelectedStu ...

Angular 2: Combining objects from various classes that extend a superclass into a single array

In my Angular 2-Native Script app, I am working on creating a service that manages an array of news items with different types such as Big, Small, Referral, each having unique parameters. The service will include various methods to manipulate this data. B ...