【发布时间】:2020-02-17 11:57:42
【问题描述】:
我想根据标志和屏幕分辨率添加类 我试过了
[ngClass]="singleFloorFlagStyle ? 'floorPlanContainerWidth' : 'singleFloor'"
@media only screen and (min-width: 1500){
.floorPlanContainerWidth{
width: 670px;
}
}
@media only screen and (max-width: 1400){
.floorPlanContainerWidth{
width: 613px !important;
}
}
.singleFloor{
width: 1300px;
}
singleFloorFlagStyle 我会收到真或假。 所以 singleFloor 类被应用但 floorPlanContainerWidth 类没有。我怎样才能使媒体查询类工作。
我已经提到了这个Angular 5: Use ngClass to switch classes for mobile and desktop views,但我想我的情况不同
【问题讨论】:
-
你的问题是类本身没有被应用还是类的样式没有被应用?因为现在你在 1400 到 1500 之间有一个 100px 的“死区”,
floorPlanContainerWidth类不会应用任何样式。 -
@Chrillewoodz 类本身没有被应用,谢谢
-
.. 你确定
singleFloorFlagStyle是真的吗? -
是的 :) 因为 singleFloor 类被应用了,所以 flag 正在工作