What is the best way to align an extensive text and an image side by side within a table cell?

I am facing an issue with my code. In one of the td elements, I have the user's name image on the left and their first name on the right. The problem arises when the first name is too long, causing the image to disappear. Everything works fine if the first name is no more than 10 characters in length.

Can anyone suggest a CSS solution to this problem?

<div *ngIf="predictions.length" class="matches-tabs__content tab-content">
        <div class="match-lineups-container tab-pane fade show active" id="tab-1" role="tabpanel">
          <div class="table-responsive">
            <table class="matches-table lineups-table lineups-table--style-3 table table-striped table-dark">
              <tbody>
                <tr>
                  <th></th>           
                </tr>
                <tr *ngFor="let prediction of predictions; index as i;">

                  <td>
                    <a [routerLink]="['/user', prediction.created_by_user_id]">
                      <figure class="match-player team-1 figure" role="group">
                        <figure class="match-player__avatar">
                          <img src="assets/img/s\amples/match-player-01-60x60.png" alt="">
                        </figure>
                        <figcaption>
                          <span class="match-player__nickname">{{ prediction.created_by_user_alias }}</span>
                          <span class="match-player__name">{{ prediction.created_by_user_first_name + " " + prediction.created_by_user_last_name }}</span>
                        </figcaption>
                      </figure>
                    </a>
                  </td>

Answer №1

If you're looking for a way to display truncated names with '...' at the end, you can achieve this by enclosing the text within a 'p' tag that has a 'text-ellipsis' class. Here's an example:

<span class="match-player__name"><p class="text-ellipsis">{{ prediction.created_by_user_first_name + " " + prediction.created_by_user_last_name }}</p></span>

You would then need to define the 'text-ellipsis' class as shown below:

.text-ellipsis {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

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

Present a two-column layout using row formatting in Bootstrap with Angular

In my component file, I have an arrayData containing 4 datas, and I am trying to display them in two columns across two rows. <div class="row"> <div class="col-md-6" *ngFor="let cat of myArrayData; let index=index"> <div clas ...

ngOnChanges is triggered only in the presence of a change

I have successfully created my own file upload component using XMLHttpRequest, and everything is functioning correctly. However, I am facing an issue with updating the progress of the upload for the user to see the percentage completion. When I use consol ...

Hidden back navigation strategy in AngularJS 2 with location strategy

After creating a custom LocationStrategy to disable browser location bar changes, I am now looking to integrate smaller apps into various web pages without affecting the browser's location. While navigation works smoothly with this new strategy, I am ...

Tips for setting up a mdl-dialog using a declarative approach

I want to incorporate a mdl-dialog into my component following the example provided here: However, when I try to do so, the compiler throws an error stating: Can't bind to 'mdl-dialog-config' since it isn't a known property of ' ...

Bringing in the MVC model class for an ASP.NET Core MVC application paired with an Angular 2 application

Currently, I am developing a sample Angular 2 application alongside ASP.NET Core MVC. I am curious if it is feasible to import a model class (let's say product.cs) that has been created in the "Models" folder directly into the Angular 2 application i ...

Do I have to use media queries if I've already specified width=device-width in my meta element?

Just a beginner question: If I'm creating a simple HTML template, nothing too complex. I include "width=device-width" in my meta element. Do I still need to incorporate media queries later on to guarantee that my template is responsive, or does incl ...

Gather the names of all properties from the filtered objects that meet specific criteria

Here is an example of an array: [ { "id": 82, "name": "fromcreate_date", "displayName": "From Create Date", "uiControl": "DATERANGE", }, { "id": 82, "name": "tocreate_date", "displayName": "To Create Date", "uiControl ...

Angular 2's ng-bootstrap datepicker popup feature allows users to easily select

Greetings! I have been exploring the ng-bootstrap datepicker and managed to implement it successfully in my application after studying the demo code. However, when attempting to add more than one datepicker input tags, only one seems to be functioning pro ...

What is the best way to eliminate the curved border and inset box shadow from the Material UI TextField component in React?

Check out this input field: https://i.sstatic.net/Z6URV.png Notice the inner shadow and curved borders. Take a look at the given code snippet: import React, {Component} from 'react'; import TextField from 'material-ui/TextField'; im ...

When you hover, there is no writing cursor in sight

I'm looking for a way to display a label on an input field and have a writing cursor show up when hovering over the label. I am not interested in using a placeholder label. Do you have any simple solutions for this? See the code snippet below: JSFiddl ...

What is the best way to modify the size of the letter background?

I'm facing an issue with a word that has a background color. While using the CSS property background-color: blue, allows me to give the word a background color and display: inline-block helps in sizing it exactly to the word, the problem arises when I ...

When switching from JavaScript to jQuery, the button values become invisible

Currently, I have a functional app that can dynamically change the values of buttons based on user input. The current implementation is in vanilla JavaScript within the script.js file. However, I am looking to enhance the functionality and user experience ...

Issue with PrimeNG overlaypanel displaying error message "Functionality of this.engine.setProperty is not available"

After importing OverlayPanelModule as @NgModule in parent.module.ts, I added the following code in child.component.html: <p-overlayPanel [dismissable]="false" #overlay> Content </p-overlayPanel> However, upon testing, I encountered the error ...

How can I ensure the footer stays at the bottom of the page using a table layout?

For quite some time now, I've been working on achieving a table layout with a sticky footer. My specific requirement is for the footer to remain fixed at the bottom even when zooming in or out. However, whenever I try to adjust the zoom level of the w ...

Display a dropdown menu when clicking on a close button in a single element using Vanilla JavaScript

I'm currently in the process of learning Javascript and trying to grasp the concept of events and selectors. My aim is to have a close button that, when clicked, triggers a specific dropdown related to the card it's attached to. I plan to achie ...

Creating an indentation on one side of a div using CSS for a visually appealing effect

https://i.stack.imgur.com/io6m0.jpg I'm in the process of trying to create two shapes using CSS. I've been able to almost achieve the first shape on the left, but it extends out too far. As for the second shape, I'm having difficulties cre ...

Why does ng serve utilize "Hash: fec054139de85795"?

Shown below is the ng serve response: Lazy Chunk Details | File Names | Size src_app_features_main-overview_main-overview_module_ts.js | app-features-main-overview-main-overview-module ...

Having trouble aligning elements in a single line using Bootstrap

I've been experimenting with different methods to align elements on the same line, such as using bootstrap and flexbox. However, I haven't been able to achieve the desired result. The goal is for the elements to stay on the same line even when th ...

Mastering error handling in Angular's Http requests

In my frontend application using Angular, I need to communicate with a RESTful webservice for the login process. The webservice returns different response codes in JSON format depending on the success or failure of the login attempt: If the login is corre ...

Having issues with the right margin in HTML5 canvas and struggling to remove the scroll bar

I am struggling with adjusting the margins of my canvas to ensure equal spacing on both sides without any horizontal scroll bars. Desired Outcome: Equal margin on both sides of canvas without any horizontal scroll bars. Issue: The margin-right property i ...