I've Angular v13 application with #angular/flex-layout also v13. The issue is Flex layout of type row wrap with Grid alignment is not working as expected. Below is the html code block. The application is hosted in stackblitz. If I remove the grid from fxLayoutGap, the layout is getting rendered without gutter space for second/subsequent rows.
<div class="cards-container" style="width: 100%; syntax: 100%;">
<div
fxLayout="row wrap"
fxLayoutAlign="start start"
fxLayoutGap="32px 12px grid"
>
<ng-container *ngFor="let item of cards">
<mat-card>
<mat-card-header>
<mat-card-title>{{ item }}</mat-card-title>
<mat-card-subtitle>subtitle</mat-card-subtitle>
</mat-card-header>
<img
mat-card-image
height="240px"
width="240px"
src="https://material.angular.io/assets/img/examples/shiba2.jpg"
alt="Photo of a Shiba Inu"
/>
<mat-card-content> </mat-card-content>
<mat-divider inset></mat-divider>
<mat-card-actions>
<button mat-button>Ok</button>
</mat-card-actions>
<mat-card-footer>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</mat-card-footer>
</mat-card>
</ng-container>
</div>
</div>
How to configure #angular/flex-layout row wrap with grid?
EDIT
Here is the solution, updated code can be accessed at stackblitz. Basically we need to wrap a div around mat-card and add fxFlex with percentage. In my case I had set it to 25 so that 4 cards come in first raw.
<div class="cards-container" style="width: 100%; syntax: 100%;">
<div
fxLayout="row wrap"
fxLayoutAlign="start start"
fxLayoutGap="32px 12px grid"
>
<ng-container *ngFor="let item of cards">
<div fxFlex="25">
<mat-card>
<mat-card-header>
<mat-card-title>{{ item }}</mat-card-title>
<mat-card-subtitle>subtitle</mat-card-subtitle>
</mat-card-header>
<img
mat-card-image
height="240px"
width="240px"
src="https://material.angular.io/assets/img/examples/shiba2.jpg"
alt="Photo of a Shiba Inu"
/>
<mat-card-content> </mat-card-content>
<mat-divider inset></mat-divider>
<mat-card-actions>
<button mat-button>Ok</button>
</mat-card-actions>
<mat-card-footer>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</mat-card-footer>
</mat-card>
</div>
</ng-container>
</div>
</div>
Related
I'm using Vue and Vuetify. I have createв the following layout:
Basically you have a card with three rows:
First row contains the number of items to display and the search bar.
Second row contains the table.
Third row contains the pagination.
Now when the screen is smaller or for example the user opens the DevTools, it shrinks the table and then the columns of the table break into separated rows. You get something like:
I'm trying to figure a way to add a horizontal bar for it not to happen. How can I make it work? Looking for solution I tried to add style="overflow-x: auto" in different locations but it didn't work.
My current code:
<div>
<v-card>
<v-card-title>
<v-row>
<v-col class="py-0">
<div class="d-flex justify-space-between align-center flex-wrap">
<div class="d-flex align-center flex-wrap my-3" id="table-view-per-page">
<div class="ml-1 inline">show</div>
<v-select
v-model="tableItemsPerPage"
:items="itemsPerPageOptions"
outlined
single-line
hide-details
dense
class="inline tiny-select inline"
></v-select>
<div class="mr-1 inline">details</div>
</div>
<div id="table-view-search">
<v-text-field
v-model="tableSearchText"
class="my-3 smooth-input mr-4"
:class="[expendSearchBar ? 'flex-grow-1' : 'tiny-input']"
append-icon="mdi-magnify"
label="search"
filled
rounded
dense
single-line
hide-details
></v-text-field>
</div>
</div>
</v-col>
</v-row>
</v-card-title>
<v-data-table
class="elevation-1"
:headers="headers"
:items="items"
:items-per-page="tableItemsPerPage"
:footer-props="tableFooterSettings"
:loading="tableLoading"
hide-default-footer
>
<template v-for="header in headers" v-slot:[`header.${header.value}`]="{ header }">
<div v-if="filters.hasOwnProperty(header.value)">
<v-select
v-model="filters[header.value]"
:items="getColumnDropdownList(header.value)"
:label=header.text
flat hide-details small clearable
class="table-column-small-select"
style="padding-bottom: 12px"
#click.capture.stop
/>
</div>
<div v-else style="padding-top: 12px; padding-bottom: 12px">
{{ header.text }}
</div>
</template>
<template v-slot:item.number="{ item }">
<a target="_blank" rel="noopener" :href="item.url">{{item.number}}</a>
</template>
</v-data-table>
</v-card>
<div class="row">
<div class="col-sm-12 col-md-9 mt-2" style="text-align: right;" id="table-view-records-info">
{{ getRecordsString() }}
</div>
<div class="col-sm-12 col-md-3 mt-2" style="text-align: left;" id="table-view-records-nav">
<v-pagination
v-model="tableCrurentPage"
primary
:length="pages"
color="#45B7FC"
style="float: left;"
></v-pagination>
</div>
</div>
</div>
you can do it by using
"width: "600px"; or any fixed width in header. By this you can force your table to be in a fixed size and the scrollbar will appear for sure.
I want to display the profile image in my project. but the image is not displayed and it shows alt word.
<div class="row">
<div class="col-md-4 col-6">
<mat-card class="example-card">
<img mat-card-image src="..\assets\images\signupbg.jpg" alt="Avatar" class="avatar">
<mat-card-header>
<div style="text-align:center;">
<mat-card-title>Samanthika Rajapaksa</mat-card-title>
<mat-card-subtitle>University of Moratuwa</mat-card-subtitle>
</div>
</mat-card-header>
<mat-card-content>
<mat-chip-list aria-label="Languages">
<mat-chip color="primary" selected>Networking</mat-chip>
<mat-chip color="primary" selected>Angular</mat-chip>
<mat-chip color="primary" selected>Aws</mat-chip>
<mat-chip color="primary" selected>Spring Boot</mat-chip>
<mat-chip color="primary" selected>My SQL</mat-chip>
</mat-chip-list>
</mat-card-content>
</mat-card>
</div>
</div>
</div>
I think the issue is with the path written way. Try as given below.
<img mat-card-image src="assets/images/signupbg.jpg" alt="Avatar" class="avatar">
Assumed as your assets folder is inside the src folder.
I'm working on a QuizSelectionComponent using Ionic. I need to adjust the ion-card's height to fit all the content in the card, longer than the height of my laptop screen. I've tried adding height: 100% !important;, height: auto !important; and height: 100vh !important; in my CSS file; but none seem to increase the height of the card. Is there a setting I can override somewhere?
My QuizSelectionComponent template looks like:
<ng-container *ngIf="quizData.length > 0">
<ion-card style="height: 100vh">
<ion-card-header>
<div class="container">
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2 logo">
<div ion-card-avatar class="header-image"></div>
</div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8">
<ion-card-title i18n>
<h1>Quiz App</h1>
</ion-card-title>
<ion-card-subtitle i18n>
<span>How well do you know Angular? Find out!</span>
</ion-card-subtitle>
</div>
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2 info">
<ion-icon name="information-circle-outline"></ion-icon>
</div>
</div>
</ion-card-header>
<section class="ion-card-content">
<mat-toolbar>
<mat-menu-button mat-button [matMenuTriggerFor]="menu">
<span i18n>Milestones ▼</span>
</mat-menu-button>
<mat-menu #menu="matMenu">
<div *ngFor="let quiz of quizData">
<button mat-menu-item
[routerLink]="['/intro/', quiz.quizId]"
data-i18n="quiz.milestone">{{ quiz.milestone }}</button>
</div>
</mat-menu>
</mat-toolbar>
<mat-grid-list cols="3" rowHeight="370px">
<mat-grid-tile
(click)="onClick()"
*ngFor="let quiz of quizData"
[routerLink]="['/intro/', quiz.quizId]"
[ngClass]="{ 'completed': status === 'completed' }"
[ngStyle]="{ 'background': 'url(' + quiz?.imageUrl + ') no-repeat center 10px',
'background-size': '300px 210px' }">
<summary class="quiz-info">...</summary>
<div class="status-icon">...</div>
</mat-grid-tile>
</mat-grid-list>
</section>
<ion-footer>
<h3 class="text-center" i18n>© 2020</h3>
</ion-footer>
</ion-card>
</ng-container>
Have you tried with: height: 100vh;
vh: Relative to 1% of the height of the viewport
https://www.w3schools.com/cssref/css_units.asp
We are currently using Angular as a front-end with fx-layout api for responsiveness.
When we are using the fxLayout="column" all elements are collapsed and doesn't seem to have any height.
What are the best practice when using fx-layout/flex to handle these scenarios ?
Using angular 9.0.0rc with flex-layout": "^8.0.0-beta.27
Browserslist setting
0.5%
last 2 versions
Firefox ESR
not dead
# IE 9-11
Here an image from IOS Safari (12)
Here an image from chrome
Here the repeated container which display the list seen in the image above
<div *ngIf="!(dataSource.loading$ | async)">
<mat-card class="pointer mb-2" *ngFor="let quotation of dataSource.quotations$ | async"
(click)="onClickRow(quotation)">
<mat-card-content fxLayout="row" fxLayoutGap.gt-xs="15px" fxLayout.xs="column" fxLayoutAlign="start center"
fxLayoutAlign.xs="center center">
<div fxLayout="column" fxLayoutAlign="center center">
<img class="profile-picture" *ngIf="authSvc.currentUser.hasSalesRights && quotation.customer.photoUrl"
[src]="quotation.customer.photoUrl" alt="">
<img class="profile-picture" *ngIf="authSvc.currentUser.hasCustomerRights && quotation.salesRep.photoUrl"
[src]="quotation.salesRep.photoUrl" alt="">
<img class="profile-picture" *ngIf="authSvc.currentUser.hasSalesRights && !quotation.customer.photoUrl"
src="https://storage.googleapis.com/edcommerce/businesslogic/images/placeholder/avatar.jpg" alt="">
</div>
<div fxLayout="column" fxFlex fxLayoutAlign.xs="center center">
<div fxLayout="row" *ngIf="authSvc.currentUser.hasSalesRights">
<span class="mat-body">{{quotation.createdDate | edDate}}</span>
</div>
<div fxLayout="row" fxLayoutAlign.xs="center center">
<span class="mat-h2 m-0">{{quotUtils.getVehicleDescription(quotation)}}</span>
</div>
<div fxLayout="row" fxLayoutGap="10px" *ngIf="authSvc.currentUser.hasSalesRights"
fxLayoutAlign="start center">
<span class="mat-body">{{ts('common.user.text.roles.customer')}}</span>
<span class="mat-body">{{quotation.customer.fullName}}</span>
</div>
<div fxLayout="row" fxLayoutGap="10px" *ngIf="authSvc.currentUser.hasBuyerRights"
fxLayoutAlign="start center">
<span class="mat-body">{{ts('common.user.text.roles.sales_rep')}}</span>
<span class="mat-body">{{quotation.salesRep.fullName}}</span>
</div>
<div fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="10px" fxLayoutAlign="start center">
<span class="mat-body">{{ts('page.quotations.text.step_required')}}</span>
<span
class="mat-body-2 color-primary">{{enumUtils.Quotation.getStatusDescByRole(quotation.status,statusTypes)}}</span>
</div>
</div>
</mat-card-content>
</mat-card>
</div>
The problem with safari occur on this element (second container in the mat-card-content):
<div fxLayout="column" fxFlex fxLayoutAlign.xs="center center">
The flex on safari resulted with a weird exponential number in the CSS something like this : flex: 1 1 1.12e-16
Changing fxFlex for fxFlex="grow" generated on safari this css flex : 1 1 100% which fix the height !
I'm using flex layout to set material card inline on desktop view and vertically on phone view .
<div fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center center" class="containercards">
<div fxFlex fxFlex.xs="100">
<mat-card class="container">
<mat-card-title>
Jeu Puissance 4 </mat-card-title>
<img mat-card-image src="../../assets/icons/puissance4.png">
<mat-card-content>
<p> Javascript, HTML/CSS </p>
</mat-card-content>
<mat-card-actions>
<button mat-button (click)="Puissance4Href()">Github</button>
<button mat-raised-button color="primary" (click)="openDialog('Puissance4')">Détails</button>
</mat-card-actions>
</mat-card>
</div>
<div fxFlex fxFlex.xs="100">
<mat-card class="container">
<mat-card-title>
Post-it </mat-card-title>
<img mat-card-image src="../../assets/icons/post-it.png">
<mat-card-content>
<p>Silex(PHP), HTML/CSS, AJAX </p>
</mat-card-content>
<mat-card-actions>
<button mat-button (click)="PostitHref()">Github</button>
<button mat-raised-button color="primary" (click)="openDialog('Postit')">Détails</button>
</mat-card-actions>
</mat-card>
</div>
<div fxFlex fxFlex.xs="100">
<mat-card class="container">
<mat-card-title>
Gestionnaire de tâches </mat-card-title>
<img mat-card-image src="../../assets/icons/planning.png">
<mat-card-content>
<p>Angular 4 , NodeJS , ExpressJS, Angular Material Components</p>
</mat-card-content>
<mat-card-actions>
<button mat-button (click)="PlannerHref()">Github</button>
<button mat-raised-button color="primary" (click)="openDialog('Gestionnaire')">Détails</button>
</mat-card-actions>
</mat-card>
</div>
</div>
The problem is that in phone view, I don't get cards with the same width size even if I set fxLayout.xs to 100.
Here's a stackblitz example.
Here I get the first and second with a smaller width, in my app only the first card have a smaller width.
Here's what I get in local
Your stackblitz doesn't include flex-layout as a dependency (and of course doesn't import FlexLayoutModule). When you include it, the flex layout code you've added will be applied and your problem will show.
You are trying to set the width of all your cards using width="70%" applied to <mat-card> but flex layout is adjusting the size of the parent <div>. And because your fxLayoutAlign setting is "center center", flex layout adjusts the widths of the divs for the row layout but not for the column layout. So the cards are actually 70%, but the divs are not. You need to apply a specific width to the divs for xs layouts. You might find that adding the xs specific layout alignment fxLayoutAlign.xs="start stretch" is all you need to do or at least a starting point. This will make all the divs full width, leaving all the cards at a consistent 70%.