代码之家  ›  专栏  ›  技术社区  ›  user5047085

<mat card>未升起-没有边框

  •  9
  • user5047085  · 技术社区  · 7 年前

    我有一个简单的html:

     <mat-card>
        <mat-card-content>
          <code>{{file}}</code>
        </mat-card-content>
     </mat-card>
    

    由于某些原因,当mat-card元素被渲染时,它不会被提升-我希望得到如下结果:

    enter image description here

    有人知道我是否遗漏了一些额外的CSS吗?我不明白。

    4 回复  |  直到 7 年前
        1
  •  14
  •   csharpsql Mahdi Shahbazi    5 年前

    我的问题是,我的风格中没有导入主题。css:

    @import "~@angular/material/prebuilt-themes/indigo-pink.css";
    
        2
  •  12
  •   brijmcq    7 年前

    你可能只需要在你的mat卡上留一个边距。

    <mat-card style="margin:2em;">
    ...more code
    </mat-card>
    

    这是stackblitz demo

        3
  •  1
  •   user5047085 user5047085    7 年前

    我认为你必须在mat卡上加一个边距,所以也许

    @Component({
      styles: [`
    
      mat-card { margin:2em;  }
    
      `]
    })
    
        4
  •  0
  •   Simon_Weaver    6 年前

    如果已实现自定义主题,请确保 mat-card 已应用此主题。这通常是应用程序根目录。

    我的自定义主题是 rr-theme-light -所以我不得不将这个类添加到 mat卡 为了让阴影出现。

    enter image description here