I'm curious if there's a method to ensure that the content within a mat-card stays responsive

So I'm working with this mat-card:

<mat-card>
 <mat-card-content>
      <div *ngFor="let siteSource of siteSources | paginate: { itemsPerPage: 5, currentPage: page};">
        <site-details [site]='siteSource'></site-details>
      </div>
    </mat-card-content>
</mat-card>

And within each element, I have some corresponding HTML:

<div *ngIf="site" class="col-xs site-details">
  <div>
    <tr>
      <td class="col-sm-6"><label>http://www.{{site._source.url}}.com.br</label></td>
      <td class="col-sm-2">
        <a routerLink="editSite/{{site._id}}" style="text-decoration: none; color: white"
          routerLinkActive="active">
          <button mat-raised-button color="primary">
            Edit
          </button>
        </a>
      </td>
      <td class="col-sm-2"><button mat-raised-button color="warn"
          (click)="openConfirmationDialog('delete',site._source.url)">Delete
        </button></td>
      <td class="col-sm-2"> <a target="_blank" href="http://www.{{site._source.url}}.com.br" title="Visit site"><button
            mat-raised-button>Visit Site</button></a>
      </td>
    </tr>
  </div>
  <hr>
</div>

<router-outlet></router-outlet>

The issue arises when switching to mobile view as the buttons extend beyond the boundaries of the mat-card:

Is there a way to ensure that the content remains responsive and contained within the mat-card when viewed on mobile?

Answer №1

Several considerations are at play here

  • The utilization of tables (tr, td) is not conducive to responsiveness; divs would be more suitable for achieving responsive design
  • The classes being utilized are Bootstrap classes and will function with <div> if the Bootstrap CSS is included (as done in index.html)
  • The combinations of col-sm-6 or col-sm-2 from Bootstrap may not align with Angular-material card due to the card having a maximum width of 400px, as opposed to the range of 576px - 768px that the col-sm grid classes are designed for
  • Therefore, applying the col-[99] classes is necessary since the width is below 576px
  • It is possible to override the padding and default min-width for very small screens in card-fancy-example.css, although such customization may deviate from the standard angular-material design

View the demonstration here - please note: the router-outlet has been removed to simplify the sample setup without routing;

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

Creating a running text (marquee) with CSS is a simple and efficient way to make

I encountered a significant challenge while delving into CSS animation. My goal is to create a "transform: translate" animation that displays text overflowing the content width as depicted in the image below. https://i.stack.imgur.com/sRF6C.png See it i ...

Strange Behavior of HTML5 Audio Elements

I'm currently in the process of designing a shop website with a nostalgic Windows98 theme. On the product's page, I want to include a preview of audio. Here is the CSS code that I have used for the HTML5 audio element: audio::-webkit-media-contr ...

What is causing the additional space at the bottom?

Why does my centered black border triangle have an extra bottom margin causing a scroll bar to appear? * { margin: 0; padding: 0; box-sizing: border-box; } body { height: 100vh; width: 100%; background: blue; } .canvas { border: 10px s ...

Navigating to a URL parameter outside of the <router-outlet>

Currently, I am developing a simulated e-commerce platform using Angular 11. The structure of my app.component.html file is outlined below: <mat-toolbar> <mat-toolbar-row> <!-- Various buttons and links --> <button *ngIf=&quo ...

Switching effortlessly between Fixed and Relative positioning

As I work on creating a unique scrolling experience, I aim to have elements stop at specific points and animate before returning to normal scroll behavior once the user reaches the final point of the page. Essentially, when div X reaches the middle of the ...

When attempting to use the ResponsiveSlides plugin, the functionality of 'Image links' seems to be disabled in the Chrome browser

While everything is functioning perfectly in Firefox and IE, I've encountered an issue with Chrome. It only works after right-clicking and inspecting the element; once I close the Inspector, it stops working - displaying just an arrow cursor as if the ...

The way Angular Material Tables Sort Alphanumeric Values

While working with the Angular Material Table, I encountered an issue where the ascending sort order is not as expected. Here's the scenario: Let's consider 5 codes: F1, F2, F5, F9, F10. The default sorting order in Angular Material Table is: ...

What is causing the issue with TypeScript's React.createRef() and its compatibility with the material-ui Button element?

Running on React version 16.13.1, my component class includes a Material-UI Button component and a RefObject to access the button element. class Search extends React.Component<any, any>{ constructor(props: any) { super(props) this.streetV ...

Steps for creating a jasmine test suite

I'm currently creating a unit test for Angular2 using Jasmine. Below is the code snippet I am working with: component.ts toggleSelect() { this.checked = event.target.checked this.tree.forEach(t => { t.checked = this.checked }) ...

What is the best way to showcase a blank div element using CSS?

Is there a way to make this empty div tag display without having to add &nbsp;? Can it be achieved using only CSS? <div class="bar bg-success" title="2015-07-23,5.0000" height="50%"></div> .bar { background: green; width: 5px; float ...

The parent's height dynamically adjusts based on the height of its visible children using only CSS

I am dealing with the following structure: <div class="body"> <div class="wrapper"> <div class="dialog"> <div class="content-0"></div> <div class="content-1&quo ...

How can you refresh the .replaceWith method in jQuery?

Is there a way to reset the .replaceWith function so that the html, css and javascript elements are restored to their original state? I am looking to have an icon replace the text when the user clicks on "contact", and then have the text return when the u ...

Angular 8 is throwing an error stating that the property 'token' is not recognized on the 'Object' data type

As a newcomer to Angular, I have been following the MEAN Stack - Mean Auth App Tutorial in Angular 2. However, since I am using Angular 8, some of the code is deprecated due to recent updates. I have encountered an issue with the code bel ...

Menu Overlay (jQuery/CSS)

I am in the process of developing a website that is optimized for both mobile and desktop devices. I am currently brainstorming ideas for the main navigation, which I envision as an overlay that slides down similar to . However, I am struggling to create ...

Simulating HTTP requests in end-to-end Protractor tests for Angular 4 application

We are currently working on a large project and have developed numerous test cases to cover various real-life user scenarios in our end-to-end functional tests. During testing, our application makes multiple REST calls to complete the test cases. When exe ...

Unique custom CSS and meta tag options for enhancing iPad/iPhone user experience

Currently, I am developing a web application that integrates Extjs components, PHP, and MySQL. My main goal is to ensure that my application looks correct on the iPad. Are there any specific CSS rules or meta tags that I should be implementing for optima ...

What steps can be taken to troubleshoot the npm start problem?

I am encountering the error shown below: https://i.stack.imgur.com/jqmcF.png This issue is present on Windows but not on Linux. Which dependency do I need to install? I can't seem to locate the Color npm dependency. ...

Disabling a Field in Angular While Preserving its Value

Hey there, late night folks! I have a quick question about Angular. I'm working with a form that includes a specific field where I set the value using patchValue, but I also need to disable this field. The issue is that after disabling it, the value i ...

What is the best way to invoke a function that is declared within a React component in a TypeScript class?

export class abc extends React.Component<IProps, IState> { function(name: string) { console.log("I hope to invoke this function"+ name); } render() { return ( <div>Hello</div> ); } } Next, can I cal ...

What is the best way to position an SVG background image at the bottom of a container?

I am facing an issue with using an SVG as a background-image on a pseudo element. The image is not as tall as the container, so I would like to position it at the bottom of the container while having the background color fill up the top portion to create a ...