Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you deal with div with mat-card-header-text in an material2 card?

I can't seem to wrap my head around having this container in an md card.

In my material cards, I have this:

<div class="mat-card-header-text"> </div> 

I've seen other people notice it. It causes a 40px space on the left of my title. No CSS seems to affect it either.

I am using Angular 4.x and Material2.

like image 327
flamusdiu Avatar asked Apr 18 '17 18:04

flamusdiu


People also ask

How can I center my mat card content?

Seems you are looking for the CSS style justify-content: center . This will center your content in the Mat-Card-Content.

How can I increase my mat card height?

The default behavior of flex-layout is to stretch components across the cross axis. In your case this is the height of the cards. This is controlled by the fxLayoutAlign property which defaults to "start stretch" . To change this, add fxLayoutAlign="start start" to your outer <div fxLayout="row"> .

What is Mat card angular?

The <mat-card> is a container for the content that can be used to insert the media, text & action in context to the single subject. The basic requirement for design the card is only an <mat-card> element that has some content in it, that will be used to build simple cards.


1 Answers

This extra div is actually quite annoying. As it turns out though, you can use shadow-piercing to apply a style to it without changing the CSS emulation mode. You can do this using the ::ng-deep combinator as such:

::ng-deep .mat-card-header-text {   /* CSS styles go here */   margin: 0px; // for example to remove the margin } 

You can also just replace the whole header with your own CSS classes instead:

<mat-card>   <div class="your-header">     <div class="your-title">       Your title here     </div>   </div>   <mat-card-content>     Stuff goes here   </mat-card-content> </mat-card> 
like image 177
Dre Avatar answered Oct 02 '22 12:10

Dre