我是angular 5的新手。我必须实现调整高度&通过使用角度5,以百分比表示div的宽度。请帮助我实现此功能。
您可以轻松地做到这一点。
<p [style.width.%]="someValue"> ... </p>
<p [style.height.%]="someValue"> ... </p>
参考
您必须在.css文件中声明css属性。
例如:
div {
height: 200px;
width: 50%;
background-color: powderblue;
}
最好在css/.ts文件中使用它
@Component({
selector: 'your-selector',
styles: [`
.change-hight-width{
height: 200px;
width:200px;
}
`]
//rest of the code
})
在html 中
<div [ngClass]="'change-hight-width'">