Tips for addressing the issue of mat-list-item not occupying the entire row's space

Hello everyone, I am currently trying to render an article.component.html within my article-list-component.html in a list format. When I use plain HTML, it renders correctly as shown in picture 1: Title - author - Date Here is the code for my article-list.component.html:

<ul>
    <li *ngFor="let article of data_array">
        <a [href]="article.url" class="undecorateda" target="_blank">
            <app-article [data]='article'></app-article>
        </a>
    </li>
</ul>

However, when I attempt to use Angular Material list, the component renders everything aligned to the left like this (see picture 2): Title-author-Date Here is the updated code for my article-list.component.html:

<mat-list>
    <mat-list-item *ngFor="let article of data_array">
        <a [href]="test">
            <app-article [data]='article' (click)="printURL(article.url)"></app-article>
        </a>
    </mat-list-item>
</mat-list>

When I stick with plain HTML in the article-list.component.html file, the rendering meets my expectations. However, when using the Angular Material code snippet in the same file, the rendering does not align properly.

Below is the content of the article.component.html file:

<div class='article-container'>

    <div class='title-container'>
        {{data.title}}
        <div class='author-container'>
            -{{data.author}}-
        </div>
    </div>

    <div class='date-container'>
        {{formatDay(data.created_at)}}
    </div>

    <div class="actions-container" id="deletebtn">
        <button mat-icon-button color="warn" (click)="deleteArticle(data._id)">
            <mat-icon>delete_forever</mat-icon>
        </button>
    </div>

</div>

And here's the CSS code for the article.component.css file:

.article-container {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: 10fr 2fr 1fr;
    height: 50px;
    background-color: #fff;
    border-bottom: 1px solid #ccc;
    align-items: center;
    padding: 0 15px;
}

.article-container>* {
    grid-row: 1/2;
}

.article-container #deletebtn {
    display: none;
}

.article-container:hover {
    background-color: #fafafa;
}

.article-container:hover #deletebtn {
    display: block;
}

.title-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    color: #333;
    font-size: 13pt;
}

.author-container {
    color: #999;
    font-size: 10pt;
    margin-top: 3px;
}

.date-container {
    color: #333;
    font-size: 13pt;
}

.title-container div {
    padding: 0 15px;
}

In summary, my goal is to integrate Angular Material list within the article-list.component.html and have it render correctly similar to how it appears in picture 1. https://i.sstatic.net/TIst3.png https://i.sstatic.net/lVZmz.png

==========================================

Answer №1

To make sure the article component and its list take up the full width, simply add a width of 100% to the article component itself.

:host {
  width: 100%;
}

For a visual example, check out this link to see how the list spans the entire width.

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

The functionality of jQuery's .hide method is not effective in this specific scenario

HTML section <div class="navigation-bar"></div> Jquery & JavaScript section function hideUserDiv(){ $('.ask-user').hide(); } var ask = '<div id="ask-user" style="block;position:absolute;height:auto;bottom:0;top ...

Looking for Angular 2 material components for dart with CSS styling? Need help centering a glyph on your page?

HTML: <div class="border"> <glyph class="center" [icon]="'star'" ></glyph> <div class="centerText"> This Is Text that is centered. </div> </div> Css: .centerText{ text-align: center ...

Ways to streamline a form containing several duplicate rows and make it more user-friendly

Looking for some advice on implementing a "working hours" module. Just need something simple like: Monday: 10:00 - 18:00 ... Saturday: 11:00-16:00 with some additional info. I'm currently attempting to... <form id="working_hours"> <s ...

When utilizing Ionic with Angular, it is difficult to access the hardware back button on mobile devices that have buttons located within the display/screen

When trying to access the hardware back button in my app, I encountered an issue where I couldn't produce an alert message to the user before the app closed. After posting a question on Stack Overflow (link of the question) and receiving help from the ...

Utilizing SetInterval for dynamically changing the CSS background image URL

I'm starting to feel frustrated with this situation... I have a solution where the CSS background is coming from a webservice. Currently, the system refreshes the entire page using HTML: <meta http-equiv="refresh" content="300" /> ... body { ...

Modifying the HTML <select> element with JavaScript

[resolved] I'm encountering an issue with the code below that is supposed to dynamically change the options in a second drop-down menu based on the selection made in the first menu. I've tried to troubleshoot the problem but haven't been suc ...

Execute the function when the control becomes visible

Currently, I possess an input control: <input id="someID" class="form-control" type="text" name="SomeData" data-ng-model="vm.SomeData"> I have a requirement to set the initial value of vm.SomeData upon user scrolling down to this control. As a begi ...

Angular 5 encountering issue with @Injectable annotation causing TypeScript error

While trying to compile my code, I encountered the following error: import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; @Injectable() export class TaskService { constructor(private http: Ht ...

Resolving Issues with Text Overlaid on an Image Hyperlink

Alright, so this problem might be a bit too complex for CSS/HTML to handle, but I'll give it a shot anyway. I have some images that are dynamically placed using the code from this website. What I want to do with these images is add a text overlay w ...

Rendering HTML5 and CSS3 on Internet Explorer 8

My coding knowledge is limited, but I am conducting research for our front-end developers. Our goal is to revamp our portal application using CSS 3 and HTML 5 in order to achieve an adaptive layout that can accommodate different browser widths. The curre ...

Neatly incorporating a checkbox into a miniaturized image

I need help with the code snippet below, where I want each thumbnail image to have a checkbox overlay. I want the images to take up all the space in the table cell without any white space above. It is essential that the "left" and "right" divs are aligned ...

Issue with uploading files in Internet Explorer using Ajax not resolved

I've been encountering an issue while uploading images using Ajax and PHP. Surprisingly, everything runs smoothly on Firefox but fails to work on Internet Explorer (I.E). Take a look at my HTML code below: <!doctype html> <head> <titl ...

Displaying maximum number of items in each row using ngFor

Is there a way to automatically create a new row within the 'td' element after the ngFor directive has generated 10 image repeats? Currently, all the images are displayed in a single td and as more images are added, they start to shrink. <td ...

Tips for customizing the color of the current date in the angular-material datepicker

I've created a function in angular-material to disable dates two days from now, but I'm struggling to change the color of the current date if it's disabled. The issue is that when the current date is disabled, it displays in a very light blu ...

css content exceeds div boundaries

Hello, I am experiencing an issue with my webpage located at . When I zoom out, the content overflows from its containing div. Setting the height to auto or 100% works fine, but the left column ends up being smaller than the right one, and using clear do ...

Best practices for transferring objects between components while navigating routes in Angular

I need some advice on handling a specific component in my project. Here is the code snippet: <div class="animal"> <a routerLink="/animal/{{animal.id}}"> <div> ... </div> </a> </div> This component receives ...

What is the best way to ensure an SVG maintains a fluid width while keeping its height constant?

My goal is to achieve the following: The SVG should dynamically scale its width to occupy 100% of the container's width. The SVG should either stretch or compress when the container's width changes, specifically affecting the wave drawn wit ...

Swapping stylesheets using a hyperlink - a simple guide

Currently, I am creating a website that utilizes PHP, XHTML strict, and jQuery. The main goal is to ensure the site is adaptable for mobile and desktop devices by implementing the principles of Responsive Web Design. This involves serving different stylesh ...

After deploying the application, the 'Access-Control-Allow-Origin' setting was not found

After deploying the same application to 2 servers (one for testing and one for production) on IIS, I encountered an issue. The application works perfectly on the first server, but not on the second one. While I am able to connect, retrieve data, and add ...

Enabling Autoplay for HTML Videos on Safari iOS 14.2

Recently, I've observed that my autoplay videos are not functioning on iPhone iOS 14.2. Surprisingly, everything was working fine prior to this version. Is there anyone familiar with a solution or workaround for this issue? Perhaps there's a met ...