Creating a responsive button inside a table can be achieved effortlessly with Angular Material table components

Help needed to ensure button responsiveness within a table. Here's how it appears on desktop and mobile screens:

Desktop View

Mobile View

The delete button is somewhat obscured in the mobile view.

This is the corresponding HTML code:

    <div class="col-md-8">
        <div class="col-md-12">
            <div class="design-header">
            <mat-form-field>
                <input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
            </mat-form-field>
            </div>
            <div class="design-container mat-elevation-z8" *ngIf="billTypeList">

            <mat-table [dataSource]="dataSource" matSort style="width: 100%">
                <ng-container matColumnDef="BillName">
                    <mat-header-cell *matHeaderCellDef mat-sort-header> Name </mat-header-cell>
                    <mat-cell *matCellDef="let row"> {{row.BillName}} </mat-cell>
                    </ng-container>

                    <ng-container matColumnDef="ConsumptionAbbr">
                    <mat-header-cell *matHeaderCellDef mat-sort-header> Abbreviation </mat-header-cell>
                    <mat-cell *matCellDef="let row"> {{row.ConsumptionAbbr}} </mat-cell>
                    </ng-container>

                    <ng-container matColumnDef="DateAdded">
                    <mat-header-cell *matHeaderCellDef mat-sort-header> Date Added </mat-header-cell>
                    <mat-cell *matCellDef="let row"> {{row.PostingDateTime | date}} </mat-cell>
                    </ng-container>

                    <ng-container matColumnDef="Action">
                    <mat-header-cell *matHeaderCellDef mat-sort-header> Delete </mat-header-cell>
                    <mat-cell *matCellDef="let row" [style.color]="row.color">
                        <button mat-raised-button class="btn btn-danger" (click)="deleteBillType(row.BillTypeID)">Delete</button>
                    </mat-cell>
                    </ng-container>

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

            <mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
            </div>
        </div>
    </div>

Seeking guidance for the correct way to address this. 

**UPDATE**
The solution provided earlier did not yield the desired outcome.
<div class="table-reponsive">
    <mat-table [dataSource]="dataSource" matSort>

    <ng-container matColumnDef="MonthNo">
        <mat-header-cell *matHeaderCellDef mat-sort-header> Month </mat-header-cell>
        <mat-cell *matCellDef="let row"> {{row.MonthNo}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="RatePerSqm">
        <mat-header-cell *matHeaderCellDef mat-sort-header> Rate Per Sq. M. </mat-header-cell>
        <mat-cell *matCellDef="let row"> {{row.RatePerSqm}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="FixedAmount">
        <mat-header-cell *matHeaderCellDef mat-sort-header> Fixed Amount </mat-header-cell>
        <mat-cell *matCellDef="let row"> {{row.FixedAmount | currency: 'PHP '}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="EffectiveDate">
        <mat-header-cell *matHeaderCellDef mat-sort-header> Effective Date </mat-header-cell>
        <mat-cell *matCellDef="let row"> {{row.EffectiveDateTime | date}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="Action">
        <mat-header-cell *matHeaderCellDef> Action </mat-header-cell>
        <mat-cell *matCellDef="let row" [style.color]="row.color">
        <button class="btn btn-primary" (click)="deleteRealPropertyTaxRate(row.RealPropertyTaxRateID)">Delete Record</button>
        <button  class="btn btn-primary" (click)="onEdit(row)">Edit Record</button>
        </mat-cell>
    </ng-container>

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

Using the "table-responsive" class proved ineffective as well.

Answer №1

To recreate your situation, I have created a table with the use of the "table-responsive" class from Bootstrap.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<table class="table table-condensed table-responsive">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Date</th>
      <th> Actions </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>November 14, 2012</td>
      <td> <button type="button" class="btn btn-danger">Danger</button> </td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>November 14, 2012</td>
      <td> <button type="button" class="btn btn-danger">Danger</button> </td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td colspan="2">Larry the Bird</td>
      <td>November 14, 2012</td>
      <td> <button type="button" class="btn btn-danger">Danger</button> </td>
    </tr>
  </tbody>
</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

What steps can I take to ensure my CSS selector for the element is functioning properly?

Here is an example of some code: <html> <head> <style> .test{ background-color: red; p { background-color: yellow; } } </style> </head> <body> <div class="test"> ...

Creating Image Overlays with Hover Effects using CSS and PHP Conditions

Looking for some assistance with a Minecraft server listing page I am working on for a client. I have never done this before and have encountered a roadblock. Take a look at this image (apologies for using Paint, I was in a hurry!) The goal is to have the ...

Is there a way to arrange the components of my form so that the questions are positioned on the left side and the choices are displayed on the right

As I am creating a form, my goal is to align the information within it in a way that places the questions on the left side and the options on the right. I have experimented with utilizing IDs, centering them, and adjusting their positioning from left to r ...

The grid layout in Bootstrap 4 does not seem to be compatible with dompdf

I am in the process of using dompdf for rendering a PDF file. Our application is built on Bootstrap 4 framework, and I want to incorporate it into the twig template used for generating our documents. However, I have encountered an issue with the Bootstrap ...

Ways to implement CSS styling for a particular HTML element

HTML: <div class="tagline">Web Portal Name</div><br /> <div id="logged_in_user_dtls" style="color:#FFF; margin-top:15px; font:bold; width:100%; position:relative; margin-left:800px;float:left;"&g ...

Effect on Label in WordPress Contact Form 7 When Input Field is Populated

Currently, I am attempting to achieve the floating label effect on Contact Form 7 and have encountered an issue. Although I have successfully implemented the label effect on input:focus, I am struggling to make it persist once text has been entered and foc ...

Unable to fix gap at the base of the jumbotron

Utilizing the jumbo tron to display a hero image of psd, there seems to be a gap at the bottom that I have tried to adjust with margin-bottom: 0px without success. .jumbotron { background-image: url(image/background.png); background-repeat: no- ...

I can't seem to figure out the source of this unexpected padding/margin on my website

After creating a website for a church using Foundation, SASS, and Compass, I noticed a horizontal scroll issue when resizing the window. Adding overflow-x: hidden; seemed to fix it, but there was still about 20px of padding on the right side when testing ...

Tips for entering the lowest and highest values into the input field

I am looking to track the daily minimum and maximum prices of shares for various companies. Currently, I'm attempting to utilize this tag: <input type="number" name="number" placeholder="minprice"> <input type="number" name="number" place ...

Adjust the size of the font based on the screen resolution

What is the best way to adjust font size based on screen resolution so that text remains as a single line when the screen is small? For example: http://prntscr.com/2qa9ze <div class="centerbreaking"> <section id="breaking-news"> <div id ...

Prevent iPhone from automatically changing phone numbers to grey text color

For some reason, the iPhone keeps changing the phone numbers on my site to grey, despite using Drupal 7. I've heard that this is because the iPhone wants to make them stand out for users to interact with. I tried adding the following code to the head ...

Display the field names from a MySQL table on a web page

Is there a way to show all column names from a MySQL table on a webpage if only the table name is known? ...

Firefox presents a compact box positioned between the images

When attempting to use flags as a way to switch between languages, I encountered an issue in Firefox where a small box appears between the images on the Hebrew site. In Chrome, everything works fine. I implemented the following code: <div class="flags ...

What is the best way to customize the interval time for my specific situation?

I'm working on setting an interval in my app and I have the following code: HTML <div class="text"> {{currentItem.name}} </div> <ul> <li ng-repeat="item in items" ng-click="pickItem($index)">{{item.type}}</li> ...

centering headers using tailwind styles

I am facing a challenge with positioning my main title, logo, and subtitle. I want the subtitle to be centered regardless of the logo's width. Currently, the position of the sub title changes based on the logo's width, resulting in it not aligni ...

Tips for mastering web design techniques

As a budding Web Designer, I am eager to absorb the most efficient techniques utilized in the world of web design. Can anyone recommend some tutorials for mastering the creation of innovative websites using Photoshop, CSS, HTML, and more? ...

Unable to align text in the middle of the header

Seeking help with my design flaws, I have created a fiddle to showcase the issues that arise when attempting to make it responsive. The main problem is that the HEADING IN CENTER text is not aligned properly in the center. If I remove the position attribut ...

Navigation buttons that move the user either up or down the page

I am a beginner in programming and I wanted to create two buttons for my webpage. One button should appear when the page is scrolled more than 300px and take the user to the top, while the other button should be displayed immediately and scroll the user to ...

Is it possible to enable CSS margins to collapse across a fieldset boundary in any way?

One interesting CSS behavior is that adjacent vertical margins typically collapse into one another. In other words, the space between elements will be equal to the larger margin instead of the sum of both margins. Interestingly, fieldset elements do not f ...

Utilizing Ant Design Icons without an Internet Connection

In my current project, a reactJS application utilizing ant design for the UI was recently deployed to production on locked down computers. These computers lack internet access, causing ant design icons on modals to appear as empty boxes. Upon investigation ...