Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mat-card, how to change default padding

I want to change the global, default padding on a Angular Material, mat-card.

In the angular.json I have this specification:

 "styles": [
          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",           
          "src/styles/app.theme.scss",
          "src/styles/styles.scss"
        ],

i make the adjustment inside of styles.scss

.mat-card {
    margin: 5px;
    padding: 5px;}

Result is that margin works, while padding does not. this is the result in the devtools. I see there is a .mat-card in <style> that takes precedence.

How do I set the padding on a global basis on a mat-card?

enter image description here

like image 953
jeff Avatar asked Jan 01 '19 14:01

jeff


People also ask

What is Mat card and paginator?

Angular Material (MAT) Card and Paginator What is the MAT Card? <mat-card> is a content container for works, photos, and text about a subject.

What is a <Mat-card> element?

<mat-card> is a content container for works, photos, and text about a subject. Basic card requires only the <mat-card> element with only some content. Although, it provides several preset sections that you can use inside <mat-card>: S. No 1.

What is <Mat-card> in Angular Material?

<mat-card> is a content container for text, photos, and actions in the context of a single subject. The most basic card needs only an <mat-card> element with some content. However, Angular Material provides a number of preset sections that you can use inside of an <mat-card>:

Can the align property be used in a <Mat-card-actions> container?

Although, the align property can be used to perform actions at the 'start' or 'end' of a <mat-card-actions> container. The card header gives the ability to add a rich header to a card section. The header can contain all of these sections:


2 Answers

You must scope them. Angular will take css of its own component first. So if you want to change globally scope them with any class name such as 'custom'.

<mat-card class="custom"></mat-card>

In stylesheet

.custom.mat-card{
  //your styles
 }

To know more, refer to angular material customizing

like image 194
Akhi Akl Avatar answered Oct 21 '22 05:10

Akhi Akl


dotless: .mat-card --> mat-card

mat-card { margin: 5px; padding: 5px;}
like image 3
Ivan Avatar answered Oct 21 '22 07:10

Ivan