Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material 6 grid list align-items and justify-content to flex-start

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;
}
like image 403
Laurence Avatar asked Aug 19 '18 17:08

Laurence


People also ask

How do you justify-content in grid?

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.

How do I center align grid items?

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.

How do I center my grid display?

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.

How do I align columns in CSS?

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'.


1 Answers

Put in styles.css:

DEMO

.mat-grid-tile .mat-figure {
   justify-content: flex-start !important ;
   align-items: flex-start !important;
}
like image 114
Akj Avatar answered Oct 15 '22 23:10

Akj