Skip to content

Instantly share code, notes, and snippets.

@killerchip
Created January 1, 2018 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerchip/8f576916dcc948c2ba59352ecc5d1798 to your computer and use it in GitHub Desktop.
Save killerchip/8f576916dcc948c2ba59352ecc5d1798 to your computer and use it in GitHub Desktop.
Angular cheatsheet: Directives/NgStyle

NgStyle

Single property

  <div [style.background-color]="'black'"></div>

Multiple properties at once

  <div [ngStyle]="{color: 'white', 'background-color': 'blue'}"></div>

With units

  <div [style.font-size.px]="13"></div>
  <div [style.font-size.em]="1.5"></div>
  <div [style.font-size.%]="45.5555"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment