角动态css#

问题描述 投票:0回答:1

这是我的CSS

#snackbar {
  float: bottom;
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #009688;
  color: #fff;
  text-align: center;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  right: 5%;
  top: 10%;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {top: 0; opacity: 0;} 
  to {top: 10%; opacity: 1;}
}

@keyframes fadein {
  from {top: 0; opacity: 0;}
  to {top: 10%; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {top: 10%; opacity: 1;} 
  to {top: 0; opacity: 0;}
}

@keyframes fadeout {
  from {top: 10%; opacity: 1;}
  to {top: 0; opacity: 0;}
}

是否可以更改typescript中的所有顶级值我需要使用@Input从html中给出最高值,是否可以使用角度2替换css“top”和css“bottom”?

css angular typescript typescript2.0
1个回答
0
投票

您需要使用ngClass:

<some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>

我认为没有别的办法。在这里阅读更多关于ngClass的信息:https://angular.io/api/common/NgClass

© www.soinside.com 2019 - 2024. All rights reserved.