Resizing height & width of the div in percentage n

2019-09-03 09:35发布

问题:

I am new to angular 5. I have to implement Resizing height & width of the div in percentage by using angular 5. Please help me to implement this functionality.

回答1:

you can do this easily.

<p [style.width.%]="someValue"> ... </p>
<p [style.height.%]="someValue"> ... </p>

ref



回答2:

you have to declare the css properties in .css file.

for example:

div {
    height: 200px;
    width: 50%;
    background-color: powderblue;
}


回答3:

Better you use it inside css/ .ts file

@Component({
  selector: 'your-selector',
  styles: [`   
      .change-hight-width{
        height: 200px;
        width:200px;
      }   
  `]
//rest of the code
    })

in html

<div [ngClass]="'change-hight-width'">