The Ionic application text is extending beyond the boundaries of the screen when using the chat application

I've integrated a chat feature into my Ionic application successfully. However, I'm facing an issue where long messages extend beyond the view. I lack skills in CSS and would appreciate any assistance to keep the text within the viewport.

Check out this image for reference

Below is my .html file content:

<ion-header>

  <ion-navbar>
    <ion-title>{{teamName}}</ion-title>
  </ion-navbar>

</ion-header>


<ion-content >

  <div class="message-wrap">
    <div *ngFor="let message of messages"
     [class]="message.username == username ? 'message left' : 'message right'"
    >
      <img class="user-img" alt="" src="http://www.newsshare.in/wp-content/uploads/2017/04/Miniclip-8-Ball-Pool-Avatar-16.png">

        <div class="msg-detail">
          <div class="msg-info">
            <p>
             {{ message.username }}
            </p>
           </div>
          <div class="msg-content">
             <span class="triangle"></span>
              <p class="line-breaker ">{{ message.message }}</p>
          </div>
          <!-- <div class="messageContent">{{ message.time }}</div> -->
          <!-- <ion-datetime class="username" displayFormat="MMM DD, h:mm A" [(ngModel)]="message.time"></ion-datetime> -->
        </div>

    </div>
  </div>

</ion-content>

<ion-footer>
  <ion-toolbar>
    <div id="footer">
      <div class="elem"><ion-textarea type="text" placeholder="Enter message here....." [(ngModel)]="message"></ion-textarea></div>
      <div class="elem"><button ion-button icon-only (click)="sendMessage()"><ion-icon name="send"></ion-icon> </button></div>
    </div>
  </ion-toolbar>
</ion-footer>

And here's my .scss file:

page-hotel-detail{


  $userBackgroundColor: #387ef5;
  $toUserBackgroundColor: #fff;


  ion-content .scroll-content {
    background-color: #f5f5f5;
  }


  .elem button {
      border-radius: 0;
      margin: 0;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
  }
  .elem {
    position: relative;
    min-width: 50px;
  }
  div#footer div.elem:first-child {
      flex-grow: 1;
  }
  div#footer {
      display: flex;
      flex-direction: row;
      align-items: stretch;
  }

  ion-input{
    padding-left: 15px;
    font-size: 125%;
  }
  ion-toolbar {
    margin: 0;
    padding: 0!important;
  }
  .message:after {
    content: '';
    display: block;
    clear: both;
  }
  .messageLeft {
    float: left;
  }
  .messageRight {
    float: right;
  }

  .message.special .innerMessage .messageContent{
    background: white;
    display: inline-block;
    padding: 0 10px;
  }

  .message.special .innerMessage:before{
    content: '';
    height: 2px;
    background: #eee;
    display: block;
    top: 50%;
    position: absolute;
    left: 0;
    width: 100%;
    z-index: -1;
  }

  .message.special .innerMessage{
    background: transparent;
    color: black;
    font-size: 80%;
    width: 100%;
    float: none;
    text-align: center;
    position: relative;
  }


    .message-wrap {
    padding: 0 10px;
    .message {
      position: relative;
      padding: 7px 0;
      .user-img {
        position: absolute;
        border-radius: 45px;
        width: 45px;
        height: 45px;
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.36);
      }

      .msg-detail {
        width: 100%;
        display: inline-block;
        p {
          margin: 0;
        }
        .msg-info {
          p {
            font-size: .8em;
            color: #888;
          }
        }

        .msg-content {
          position: relative;
          margin-top: 5px;
          border-radius: 5px;
          padding: 8px;
          border: 1px solid #ddd;
          color: #fff;
          width: auto;

          span.triangle {
            background-color: #fff;
            border-radius: 2px;
            height: 8px;
            width: 8px;
            top: 12px;
            display: block;
            border-style: solid;
            border-color: #ddd;
            border-width: 1px;
            -webkit-transform: rotate(45deg);
            transform: rotate(45deg);
            position: absolute;
          }
        }

      }
    }

    .message.left {
      .msg-content {
        background-color: $toUserBackgroundColor;
        float: left;
      }
      .msg-detail {
        padding-left: 60px;
      }
      .user-img {
        left: 0;
      }
      .msg-content {
        color: #343434;
        span.triangle {
          border-top-width: 0;
          border-right-width: 0;
          left: -5px;
        }
      }

    }

    .message.right {
      .msg-detail {
        padding-right: 60px;
        .msg-info {
          text-align: right;
        }
      }
      .user-img {
        right: 0;
      }
      ion-spinner {
        position: absolute;
        right: 10px;
        top: 50px;
      }
      .msg-content {
        background-color: $userBackgroundColor;
        float: right;
        span.triangle {
          background-color: $userBackgroundColor;
          border-bottom-width: 0;
          border-left-width: 0;
          right: -5px;
        }
      }

    }

  }
}

Answer №1

Resolved the issue by incorporating the following code

 width:200px;
 word-wrap: break-word;

into the CSS style

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

At smaller desktop resolutions, the 1px border thickness for tables may fluctuate

The border thickness of my table is inconsistent at 1px. This issue only occurs in smaller desktop breakpoints and works fine on higher resolutions. Attached below is a screenshot for reference. https://i.sstatic.net/gPsaT.png Below is the code I used to ...

Position the table footer on the right side of the page

I am trying to format a table with footer items in HTML. I want the first footer item to be aligned left and the rest to be aligned right. Here is the desired layout: https://i.sstatic.net/ZRNEp.png table { width: 100% } <table class="price-list" ...

A fixed-height div with scrolling capability within a bootstrap column

I am new to CSS and hoping this issue is a simple one. Imagine I have a responsive, two-column Bootstrap 3 grid layout. In the left column, I want it to always fill the height of the browser window. However, within that column, I need a scrollable div to d ...

Alter the font color once the page has finished loading

Is there a way to change the color of the "View Results" text below? <script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6352993.js"></script> <noscript><a href="http://polldaddy.com/poll/6352993/"> ...

"Personalized labels for enhancing user insights on Microsoft Clarity

Is there a way to add a custom tag on MS Clarity specifically for tracking a user clicking the cancel button during a particular event? I am working on an Angular project and need guidance on how to achieve this. I attempted using script tags within the H ...

What is the best approach for ensuring optimal maintainability when components X and Y rely on shared data?

When components X and Y are children of component A and share data obtained from a REST API call, what is the most efficient method or pattern to handle this situation? Considering that the API data is not updated frequently, the ideal approach would invo ...

Button, anchor not aligned horizontally due to differing padding

I've been pondering this question for quite some time now. Whenever I try to style a button in HTML using the a tag or button tag with equal padding on the top and bottom, the buttons still align horizontally. Please refer to the image below for clari ...

Shrink Table Column Size with Bootstrap and Stylus to Optimize Space Usage

Currently experimenting with Bootstrap to ensure my table is responsive on a search list I am developing. However, I am facing an issue where two of my columns are taking up more space than necessary. In the image below, you can see that Date and Link colu ...

Using HTML and CSS to stack a DIV on top of another using z-index

I have 3 main layers on my website: 1) The main view with elements inside (#views in jsbin) - BOTTOM LAYER 2) An overlay (with a white background opacity of .8 #overlay in jsbin) - MIDDLE LAYER 3) A context menu (#contextmenu in jsbin) - TOP LAYER Wh ...

Can someone share with me the best practices for implementing @HostListener within a method in my Angular 16 project?

Currently, I've been involved in developing a Single Page Application using Angular 16, TypeScript, and The Movie Database (TMDB). My task at hand is to implement the "infinite scroll" functionality on a particular component. To achieve this, I have ...

Ways to change the CSS styles of components within App

When my app is in full screen mode, I need to increase the font size for certain components. Within my App.jsx file, I have a variable that adds the "fullscreen" class to the root DIV of the app when triggered. Instead of using a blanket approach like * ...

What is the rationale behind browsers on OSX not supporting the styling of HTML option elements?

As an OSX user, I primarily use Chrome and recently discovered that styling the HTML option element is not applied in any browser (Chrome, Firefox, Safari) on OSX. // HTML <select> <option class="option">Value 1</option> < ...

What is the clarification on Angular's paramMap.getAll method?

Angular 4 introduced support for paramMap along with get and getAll methods : I comprehend this code snippet that retrieves the value of "id" route.paramMap.subscribe( params => this.productID = params.get('id') ); However, I am c ...

What's the best way to eliminate blank space in my Bootstrap grid columns?

I'm facing an issue with the search filter layout on my website. It includes input fields for a search term, two datepickers, and two buttons: <div id="search-holder"> <div id="search-box"> <div ...

Displaying the contents of a slot in various locations within a web component

The Challenge I am currently utilizing Angular and its Angular Elements to produce Webcomponents. My goal is to allow clients the flexibility to pass custom icons into slots, enabling them to control the appearance of the icons being used. However, this ...

Is there a way I can implement jQuery animation on my pop-up window?

I've successfully set up a basic popup using jQuery. When a button is clicked, it changes the 'display' property of a div from 'none' to 'block' in CSS and creates an overlay to darken the background. Take a look at my c ...

Ways to set the initial value of an input[range] in Angular2 when the value exceeds 100

After encountering a similar issue with AngularJS, I posted a question on StackOverflow titled How to initialize the value of an input[range] using AngularJS when value is over 100. As I dive into learning Angular2, I am curious if it handles initializatio ...

Text overflow doesn't seem to be functioning properly when using a horizontal box-orient in a box

I am having trouble making the text in my box display properly render an ellipsis. It is currently overflowing beyond the containing element. HTML: <div class="outer hbox"> <div class="hbox left-container"> <div class="label no-wrap ...

What is the best way to ensure that third tier menus open in line with their respective items?

Check out this fiddle link: http://jsfiddle.net/Wss5A/72/ Focusing on the following: 2-A-1 2-A-2 2-A-3 The third-tier menu is currently displayed starting from the top left corner. I want the first submenu element to be aligned with either 2-A-1, 2-A- ...

Is there a way to align just one side of a stacked container and container-fluid in Bootstrap 5?

I am currently working on a design project using Bootstrap 5 where the navbar is contained and the hero header section below extends beyond the container's boundaries only on the right side. Below is an image depicting the design I am aiming for: ht ...