I have the following code in my .html file of my sale component:
<div>
<mat-card class="mat-elevation-z0">
<div style="text-align:center;">
<mat-card-title>Nueva Venta</mat-card-title>
</div>
<mat-card-content>
<mat-label class="title"> Fecha/Hora: {{ jstoday }}</mat-label>
<br>
<form [formGroup]="ventaForm">
<div class="container" fxLayout="column" fxLayout.gt-xs="row" fxLayoutGap="20px" >
<ng-template matStepLabel>Condicion de Venta</ng-template>
<mat-form-field appearance="fill" fxFlex="25">
<mat-label>Condicion.:</mat-label>
<mat-select #condVenta placeholder="Condicion de Venta" formControlName="condicionVenta" (selectionChange)="selectCV($event.value)" cdkFocusInitial>
<mat-option value=undefined>Seleccione</mat-option>
<mat-option value=1>Contado</mat-option>
<mat-option value=2>Cuenta Corriente</mat-option>
</mat-select>
</mat-form-field>
<span class="fill-space"></span>
<mat-form-field appearance="fill" class="example-full-width" fxFlex="75" >
<mat-label>Cliente</mat-label>
<input matInput #icliente
aria-label="Cliente"
[matAutocomplete]="auto"
[formControl]="clienteCtrl"
formControlName="nombre_cliente">
<mat-autocomplete #auto="matAutocomplete" >
<ng-container *ngFor="let c of filteredClientes | async" >
<mat-option id="c.idcliente" *ngIf="c.nombre_cliente=='CONSUMIDOR FINAL'" [value]="c.nombre_cliente" (onSelectionChange)="selectC(c)">
<span>{{c.nombre_cliente}}</span>
</mat-option>
<mat-option *ngIf="c.nombre_cliente!=='CONSUMIDOR FINAL'" [value]="c.nombre_cliente + ' CUIT: '+ c.CUIT" (onSelectionChange)="selectC(c)">
<span>{{c.nombre_cliente}}</span> |
<small>CUIT.: {{c.CUIT}}</small>
</mat-option>
</ng-container>
</mat-autocomplete>
</mat-form-field>
<br>
<table mat-table tabindex="4" #table [dataSource]="carritoDataSource$" class="mat-el" class="mat-elevation-z1" matSort class="mat-elevation-z8" matSortActive="nombreProducto" matSortDirection="asc" matSortDisableClear>
<caption style="font-size: 20px;height: 4vh;border: 10px; color: rgb(54, 11, 211);"> DETALLE </caption>
<ng-container matColumnDef="nombreProducto">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Descripcion</th>
<td mat-cell *matCellDef="let element">{{element.NombreProducto}}</td>
</ng-container>
<ng-container matColumnDef="precio">
<th mat-header-cell *matHeaderCellDef>Precio</th>
<td mat-cell *matCellDef="let element">{{element.precio | currency:'$'}}</td>
</ng-container>
<ng-container matColumnDef="categoria">
<th mat-header-cell *matHeaderCellDef>Categoria</th>
<td mat-cell *matCellDef="let element">{{element.nombre_categoria}}</td>
</ng-container>
<ng-container matColumnDef="subcategoria">
<th mat-header-cell *matHeaderCellDef>Subcategoria</th>
<td mat-cell *matCellDef="let element">{{element.nombre_subcategoria}}</td>
</ng-container>
<ng-container matColumnDef="marca">
<th mat-header-cell *matHeaderCellDef>Marca</th>
<td mat-cell *matCellDef="let element">{{element.nombre_marca}}</td>
</ng-container>
<ng-container matColumnDef="stock">
<th mat-header-cell *matHeaderCellDef>Stock</th>
<td mat-cell *matCellDef="let element">{{element.stock}}</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef>Acciones</th>
<td mat-cell *matCellDef="let element">
<button mat-raised-button color="basic">Editar</button> |
<!-- <button (click)="delete(element)" mat-raised-button color="warn">Eliminar</button>-->
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="columnas"></tr>
<tr mat-row *matRowDef="let row; columns:columnas"></tr>
</table>
<mat-paginator #productsPaginator [pageSizeOptions]="[50, 100,200]" showFirstLastButtons aria-label="Seleccionar pagina">
</mat-paginator>
</div>
</form>
</mat-card-content>
</mat-card>
</div>
But I don't understand why it appears as in the image:
The idea is that the sale condition select occupies 25% of the line or row and the rest of the space (75%) is occupied by the Customer name input, for example.
There is a problem with the fxLayoutGap directive, which is the one that defines the space between the flex items inside the container since it adds margin-right or margin-bottom and could conflict with Default value nowrap. In order to control that the flex items remain in a same line or flow in several we must use warp and calc if not! we want to force with a css configuration that produces unexpected effects by not properly taking into account the effect of fxLayoutGap For this: You have to calculate the size of the flexible elements to be able to use row warp!! considering the size fxLayoutGap so that the items are displayed as we want warp allows the elements to flow in several lines Also, if we leave the table outside the container, it happens that: As I told you, the view shows a select of sale condition occupying 25% of the line or row and the rest of the space (75%) is occupied by the Customer name input if the table does not belong to the container and the result is shown in the browser in the photo. The code that I copied as an answer can also be seen on github which contains fxLayout="column " fxLayout.gt-xs="row warp" fxLayoutGap="20px" and the way to calculate with calc since it shows how to have control over the flex elements path card github code
So we add elements to the container since we must consider the size of fxLayoutGap
Finally table inside the container: