[英]How to make styles.css in Angular not affect every element with that selector?
I can align the content of my grid tiles but I only ever wanted it to affect the table that was inside of a grid. 我可以对齐网格图块的内容,但我只希望它影响网格内的表。
I have this: 我有这个:
.mat-grid-tile .mat-figure {
justify-content: flex-start !important ;
align-items: flex-start !important;
}
EDIT: This piece of css above came from this previous solutution: Angular Material 6 grid list align-items and justify-content to flex-start 编辑:上面的这段css来自此先前的解决方案: Angular Material 6网格列表对齐项和证明内容以开始伸缩
in styles.css
but obviously it affects everything that's inside of a tile but I only want it to affect my mat-table
. 在styles.css
但显然它会影响tile内的所有内容,但我只希望它影响我的mat-table
。 Is there a way to make this not be the case? 有没有办法使情况并非如此?
<mat-grid-list id="parentGrid" cols="4" rowHeight="100px">
<mat-grid-tile colspan="1" rowspan="1">
<h1>Foo</h1>
</mat-grid-tile>
<mat-grid-tile id="table" colspan="3" rowspan="6">
<table mat-table [dataSource]="someArray">
<!--- removed for space -->
</table>
</mat-grid-tile>
</mat-grid-list>
I'll have everything aligned to the top left but I just want my table to be in the top left and have tried doing #table
and in the table's tile I would have id="table"
but this wouldn't work. 我将所有内容都对齐到左上角,但是我只想让我的表位于左上角,并尝试执行#table
并且在表的#table
贴中我将设置id="table"
但这是行不通的。
Try by replacing the CSS rule given by you with the below one: 尝试将您给定的CSS规则替换为以下规则:
.mat-grid-tile > table {
justify-content: flex-start !important ;
align-items: flex-start !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.