angular - Angular 中 <center> 的替代品是什么?

标签 angular

Error: Template parse errors:
'center' is not a known element:
1. If 'center' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
  [ERROR ->]<center><h2>my-candid works!</h2>
  <div [style.color]="isSpecial ? 'red' : 'green'">This is style bi"): ng:///AppModule/MyCandidComponent.html@1:2

最佳答案

您只是想将文本居中吗?

<h2 [ngStyle]="{'text-align': 'center'}">my-candid works!</h2>

或者将 div 居中,您始终可以使用 CSS,例如:

.yourDiv {
    margin: 0 auto;
}

关于angular - Angular 中 <center> 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46367201/

相关文章:

d3.js - 将 D3 与 Angular-cli 集成

angular - "Type ' 对象 ' is not assignable to type"带有新的 HttpClient/HttpGetModule

javascript - 如何在调整窗口大小时保持 chartjs/ng2-charts 渐变?

angular - 根据条件动态添加/删除验证器

angular - 无法更新 Angular CLI

angular - 身份验证 - VS 2017 15.3; ASP.Net Core 2.0; Angular

css - 在 Angular (4) 应用程序组件中包含外部 css

javascript - 有没有更干净的方法来消除方法的抖动?

html - 指向特定 Angular 2.0 SPA 状态的外部链接不起作用

angular - @Viewchild 看不到matSort