相关疑难解决方法(0)

如何使用Flexbox中的媒体查询控制每行的项目数?

所以想象我有以下标记

<div class="container">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

以下款式 (SASS)

@mixin max-width($width) {
    @media screen and (max-width: $width) {
        @content;
    }
}

.container {
    display: flex;

    @include max-width(992px) {
        number: 4; //Hypothetical property that is supposed to control number per row
    }

    @include max-width(640px) {
        number: 2; //Hypothetical property that is supposed to control number per row
    }
}
.item {
    background-color: tomato;
    padding: 20px;
    margin-right: …
Run Code Online (Sandbox Code Playgroud)

css sass media-queries flexbox

37
推荐指数
1
解决办法
8万
查看次数

带有 ngFor 的 Angular Flex 布局,每行 X 个元素

我试图按照这篇文章Angular flex-layout with ngFor来做我想做的事,但我做不到。

我有这个代码:

<div *ngFor="let room of listRoom;">
  <div class="room">
    Room {{room.label}}
    <div *ngFor="let bed of room.beds;">
      <div class="bed">
        Bed #{{bed.label}}
        <button mat-raised-button color="accent" (click)="assignThisBed(bed)">
          Assign this bed
        </button>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的listRooms元素通常在 10-15 个元素之间,我想连续有 3 个房间,然后是隔断线,3 个房间,......

有人能帮我吗?谢谢..

这是带有我的代码的StackBlitz

angular-flex-layout angular

6
推荐指数
1
解决办法
4546
查看次数