CSS到多个垫子响应

发布于 2025-02-09 10:44:31 字数 1025 浏览 0 评论 0原文

我有一个具有角度材料的项目,其中我正在创建一个带有几张垫子卡的组件。我要做的是根据卡的宽度使屏幕响应。

目前,只有该卡较小,但不是标题或内容。所有卡都出现在单列中。

这是我的component.html:

<div class="container">
      <mat-card *ngFor="let properties of menuComponent.fillerNav" class = "mat-elevation-z4">
        <mat-card-header>
          <mat-card-title>
            {{properties.name}}
            <mat-icon class="iconMenu">{{properties.icon}}</mat-icon>
          </mat-card-title>
        </mat-card-header>
        <mat-divider></mat-divider>
        <mat-card-content>
          <p>
            total
          </p>
        </mat-card-content>
      </mat-card>
</div>

这是我的component.scss:

mat-card {
  width: 20%
}

这是带有f12的窗口的视图:

“在此处输入图像说明”

I have a project in Angular material in which I am creating a component with several mat-cards. What I am trying to do is make the screen responsive depending on the width of the cards.

Right now only the card is made smaller but not the titles or the content. And all the cards appear in a single column.

This is my component.html:

<div class="container">
      <mat-card *ngFor="let properties of menuComponent.fillerNav" class = "mat-elevation-z4">
        <mat-card-header>
          <mat-card-title>
            {{properties.name}}
            <mat-icon class="iconMenu">{{properties.icon}}</mat-icon>
          </mat-card-title>
        </mat-card-header>
        <mat-divider></mat-divider>
        <mat-card-content>
          <p>
            total
          </p>
        </mat-card-content>
      </mat-card>
</div>

This is my component.scss:

mat-card {
  width: 20%
}

This is the view of the window with F12:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2025-02-16 10:44:31

为了使其在html上使用,以这种方式尝试

.flex-me 
{   display: inline-flex; 
  flex-flow: row wrap;    
}
mat-card{
    width: fit-content;
}

也是一个完整的示例如何使用Flex布局在Angular中创建响应式卡网格

To make it work on HTML try it this way

.flex-me 
{   display: inline-flex; 
  flex-flow: row wrap;    
}
mat-card{
    width: fit-content;
}

Also here is a full example how to create a responsive card grid in Angular using Flex Layout

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文