【发布时间】:2019-04-12 09:28:29
【问题描述】:
我正在做一个有角度的项目。我在哪里需要将动态类设置为 HTML 元素问题是我无法为动态类正确设置样式。我尝试了以下资源来更正我的 CSS
https://css-tricks.com/the-sass-ampersand/
https://dev.to/sarah_chima/nesting-in-sass-bme
<div fxLayout="row" class="header-style"
[ngClass]="dynamic_class" fxFill>
<div fxLayout="row" fxLayoutAlign="start center">
<mat-icon svgIcon="{{ icon_path }}" aria-label=""></mat-icon>
</div>
</div>
<!-- following is different div in same html -->
<div fxLayout="row" class="footer-style"
[ngClass]="dynamic_class" fxFill>
<div fxLayout="row" fxLayoutAlign="start center">
<mat-icon svgIcon="{{ icon_path }}" aria-label=""></mat-icon>
</div>
</div>
所以我想为 dynamic_class 编写 CSS,它用于两个不同的 div,并且会有不同的样式,如下所示
dynamic_class { //this is for header i.e. 1st div
padding: 12px;
}
dynamic_class { //this is for footer i.e. 2nd div
padding: 12px 8px;
}
【问题讨论】: