html - Angular2模态弹出定位左

标签 html css angular typescript modal-dialog

我正在使用 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/

相关文章:

html - 如何更改单选按钮的颜色和样式

html - 使用 css 的标签和输入布局

css - 包含@font-faces 的特定语言 LESS 类不起作用

html - 堆叠文本与网页横幅中的 Logo 对接

Angular 4延迟加载不加载组件

javascript - 使数据属性表现得像 anchor

html - 平行四边形文本框

html - 为什么不继承容器高度,当它的大小是最小高度时?

html - 以 Angular 6 动态更改复选框的工具提示文本

javascript - Angular 12 抛出此错误 FATAL ERROR : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory