Angular material tables are displaying borders that do not extend the full length

I am currently working on designing a visually appealing table. Due to the upcoming content in the matrix section, I am unable to make the table smaller for mobile devices. Therefore, I have added overflow:auto to enable a scroll-bar.

The issue I am facing is that the horizontal lines do not extend across the entire table; they are cut off behind the scrollbar.

Before scrolling

After scrolling

HTML

  <ng-container matColumnDef="module">
    <mat-header-cell *matHeaderCellDef [ngClass]="'smallCell'"> Module</mat-header-cell>
    <mat-cell *matCellDef="let moduleData" [ngClass]="'smallCell'"> {{moduleData.module}} </mat-cell>
  </ng-container>

  <ng-container matColumnDef="specialisation">
    <mat-header-cell *matHeaderCellDef [ngClass]="'smallCell'"> Spec</mat-header-cell>
    <mat-cell *matCellDef="let moduleData" [ngClass]="'smallCell'">
      <mat-list dense>
        <mat-list-item *ngFor="let specialisation of moduleData.specialisation"> {{specialisation}}</mat-list-item>
      </mat-list>
    </mat-cell>
  </ng-container>

  <ng-container matColumnDef="period">
    <mat-header-cell *matHeaderCellDef [ngClass]="'smallCell'"> Periode</mat-header-cell>
    <mat-cell *matCellDef="let moduleData" [ngClass]="'smallCell'"> {{moduleData.period}} </mat-cell>
  </ng-container>

  <ng-container matColumnDef="matrix">
    <mat-header-cell *matHeaderCellDef [ngClass]="'matrixCell'"> Matrix</mat-header-cell>
    <mat-cell *matCellDef="let moduleData" [ngClass]="'matrixCell'"> {{moduleData.matrix}} </mat-cell>
  </ng-container>

  <ng-container matColumnDef="endRequirements">
    <mat-header-cell *matHeaderCellDef [ngClass]="'requirmentCell'"> Eindeisen</mat-header-cell>
    <mat-cell *matCellDef="let moduleData" [ngClass]="'requirmentCell'">
      <mat-list>
        <mat-list-item *ngFor="let requirement of moduleData.endRequirements"> {{requirement}}</mat-list-item>
      </mat-list>
    </mat-cell>
  </ng-container>

  <mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
  <mat-row *matRowDef="let moduleRowData; columns: displayedColumns;"></mat-row>
</mat-table>

CSS

.table-container{
  height: calc(100vh - 114px);
  overflow: auto;
}

.requirmentCell{
  flex: 0 0 325px;
}

.matrixCell{
  flex: 0 0 550px;

}

.smallCell{
  flex: 0 0 110px;

}

edit Upon further investigation, it seems that it's not just the border that is being cutoff. Any CSS properties such as background color and headers are also affected.

Answer №1

I encountered a problem where the styles were only being applied to the visible portion of the table, and the part that was hidden behind a scroll did not have borders. To solve this issue, I simply added display: table to the mat-table element:

.table-wrapper {
  overflow-x: auto;
}

mat-table {
  display: table;
}

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

Another approach to utilize JavaScript for populating content into a <div> container?

Upon loading the page, I aim to display a message in the <div> element. Below is the HTML and JavaScript code I have implemented: <body onload="printMsg()"> <div id="write"></div> </body> function printMsg() { var no ...

What is the best way to display an HTML array?

I'm currently facing an issue with rendering an array containing both <p> and <div> items as HTML. Despite my attempts to render them properly, the values appear as plain code instead of formatted paragraphs. To illustrate, let's cons ...

Ordering columns inside columns with responsive design in Bootstrap 5

Could the layout be rearranged for md+ devices to this configuration on xs, sm devices? <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294b46465d5a5d5d5b4859691c07 ...

How can I make my webpage fill the entire width of an iPhone screen when in landscape mode using Angular or React?

While testing my website on my iPhone, I noticed a significant gap appearing on either side of the app in landscape view in Safari. Is there a solution to fix this issue? The problem occurs in both Angular and React applications, examples of which are disp ...

Ways to display JSON in a structured format on an HTML page

Is there a way to display JSON in a formatted view on my html page? The JSON data is coming from a database and I want it to be displayed neatly like the following example: { "crews": [{ "items": [ { "year" : "2013", "boat" ...

Displaying recorded information from PHP/MySQL dropdown menu

My never-ending problem requires a simple solution. Despite searching online and in books, I can't seem to crack it. My goal is to display results from a drop-down menu that is currently connected to a database/table and showing the l_state as require ...

Rampant number of objects contained within box element

I am currently working on a box component that contains flex items. Unfortunately, I am facing an issue where the box width remains constant and causes overflow when I try to reduce its size in order to accommodate all the items. Can anyone provide guidanc ...

Looking for a custom header logo that seamlessly blends with your image slider?

I'm just starting to learn about HTML and I'm trying to create a header with a logo overlapping on an image slider. I followed the method mentioned in this post: How would you make two <div>s overlap? Unfortunately, I'm still having t ...

"Facing Issues with lite-server crashing while setting up Angular 2 Quick

Hello Internet folks, Welcome Working through the Angular2 Quickstart guide has been quite a journey. I've encountered several instances where the lite-server would crash right after running npm start. The crash would be displayed like this in your ...

Setting the value of a select input in a reactive form

I am facing an issue with autofilling the select input on my form. Even though I've written the code, the value of the select field remains empty when the form loads. In my code, I have declared a static array of objects called extensions which conta ...

Encountering an error message stating "Unable to access property 'injector' as null when attempting to downgrade Angular 2 service."

Hello everyone, I could use some assistance with a particular issue I'm facing. Below is the code snippet from my angular 1.x app.js: angular.module('app', []); angular.module('app.test', ['app']) .config(($statePr ...

What could be causing the dropdown menu to malfunction on certain pages?

A few days ago, I attempted to learn Django and create a simple website using it. However, for some reason, the dropdown on the homepage was not functioning properly. Oddly enough, on another page, the dropdown worked perfectly fine. Here is the HTML templ ...

Make sure to deselect all other radio buttons when selecting one, running into difficulties

Having an issue with my UI when selecting radio buttons by clicking on a div: A loop that displays different radio buttons: {% for product in collections.regalos.products %} <li class="grid__item large--one-third gift-card"> <div class="gift-s ...

The PHP implementation of Google reCAPTCHA is malfunctioning when combined with AJAX

I have a form on 100.php that makes an AJAX call to 200.php. <html> <head> <!-- Include the reCAPTCHA API JavaScript library provided by Google --> <script src='https://www.google.com/recaptcha/api.js'></script ...

What's the best way to enable touch scrolling for items within a div container?

I am in the process of creating a code snippet that will allow users to scroll through items within a div, similar to a spinning wheel or slot machine. While I am aware of an existing solution for iPhone and iPod, I want to develop a simpler, more streamli ...

Can anyone suggest a stellar sprite generator for me?

I am in search of a sprite generator to streamline my web development process. With so many options available, I am seeking recommendations for the best tool. Ideally, I want a generator that can produce both a sprite image and corresponding CSS files wi ...

What is preventing the inner box from stretching to match the width of the outer box?

This question isn't really related to academics, it's more of a work-related inquiry that I've simplified into a basic question. I placed one div inside another expecting the inner div to inherit the width of the outer div. Initially, this ...

Incorporate jQuery to add numbering to rows along with input fields

I am trying to implement automatic numbering on the first column. Is there a way to increment the number by 1 every time the Submit button is pressed? jQuery: $(document).ready(function () { $("#btn-add").click(function () { va ...

Animation event in CSS3 fails to trigger on Firefox browser

Exploring the potential of CSS3 animation to detect when an input transitions from the enable to disable state, I encountered a challenge specifically in Firefox. Here is the code snippet that showcases the issue: View Demo on jsFiddle HTML: <input t ...

What is the process for invoking a service from a component?

I'm currently facing an issue with my service that is responsible for making HTTP requests and returning responses. The problem arises when I try to display parts of the response on the screen within my component, as nothing seems to be showing up des ...