I'm trying to use Angular Material 6 Dynamic grid-list. The example relating to the documentation puts contents of the grid in the centre of each tile. See example here
I want the content to go in the top left hand corner of each tile.
I have tried the following css which does not work.
.mat-grid-tile .mat-figure {
justify-content: flex-start;
align-items: flex-start;
}
justify-content You can use the following values: start , end , center , stretch , space-around , space-between , or space-evenly . The grid content is aligned horizontally to the far edge of the container element. The grid content is spaced evenly horizontally within the container element.
One of the easiest ways of centering the content of grid items is using Flexbox. Set the display to "grid" for the grid container, and "flex" for grid items. Then, add the align-items and justify-content properties, both with the "center" value, to grid items.
To center the <div> element horizontally using grid. Use the property of display set to grid i.e. display: grid; Then use property place-items: center; Example: The following example demonstrates to set the <div> to the center using grid property.
For aligning columns to the left, the align-content property will set to 'flex-start'. For aligning columns to the right, the align-content property will set to 'flex-end'. For aligning columns to the extreme ends, the align-content property will set to 'space-between'.
Put in styles.css
:
DEMO
.mat-grid-tile .mat-figure {
justify-content: flex-start !important ;
align-items: flex-start !important;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With