我正在使用 This modal在 angular2 中,我想将模态弹出窗口定位在左侧,这是我尝试过的
<modal #categoriesmodal [cssClass]="modalchecklist">
<modal-header [show-close]="true">
<h4 class="modal-title">I'm a modal!</h4>
</modal-header>
<modal-body>
Hello World!
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>
关于css类
.modalchecklist{
position:absolute;
top:0;
left:0
我尝试在 css 类上添加 //background color:red
但这失败了,并将 css 添加到背景文档而不是模态上
我在 css 类上哪里出错了
我也检查了 chrome 开发者工具,但他们也没有解决问题。
可能是哪里出了问题
最佳答案
要在 Angular2 中应用样式属性,您可以使用 [style]
指令,如下所示
<what-ever [style.backgroundColor]="'red'">I am red</what-ever>
要应用一个类,请使用 ngClass :
<what-ever [ngClass]="'first'"><what-ever>
<what-ever [ngClass]="['first', 'second']"></what-ever>
<what-ever [ngClass]="{'first':true, 'second':conditionExp}"><what-ever>
请参阅上面的 ngClass
链接,了解多个语法选项和使用表达式。
请注意,所有这些方法都是指令,直接绑定(bind)到范围,它们需要表达式。为了传递字符串,您需要将表达式限定为字符串:在双引号 中使用单引号,它们将被正确评估为字符串。
关于html - Angular2模态弹出定位左,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42313417/