html - 使用 [style.something.px] ="2"以 Angular 定义边框宽度(厚度)

标签 html css angular typescript

目前,我正在使用以下语法定义元素宽度:

<div [style.width.px]="size" [style.height.px]="size"></div>

我想要的是使用类似的语法来定义 border-width css 属性,如下所示:

<div [style.border-width.px]="borderSize"></div>

我怎样才能做到这一点?

最佳答案

我发现我可以做这样的事情:

// Html
<div [style.borderWidth.px]="borderSize"></div>

// Typescript
@Component(...)
export class LoaderComponent {
    borderSize = 2;
}

关于html - 使用 [style.something.px] ="2"以 Angular 定义边框宽度(厚度),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58821370/

相关文章:

css - 为什么 `not (some-width: Xem)` 媒体查询永远不会触发?

javascript - 在 Angular 4 中导入外部 js 文件并访问函数和变量

node.js - 错误node_modules/@types/node/globals.d.ts(196,5) errorTS2300 : Duplicate identifier 'resolve' src/typings. d.ts(12,3)重复标识符 'resolve'

javascript - 根据可用镜像添加、删除 "Active"类 bootstrap carousel

javascript - HTML:在 div 中设置图像的最大宽度

javascript - 在花括号 AngularJS 中访问窗口高度?

javascript - IE7 中的圆形悬停区域

javascript - 仅显示表中的某些列

javascript - 如何使用切换按钮更改 colSpan 的值

javascript - 将参数传递给映射的可观察对象