DiviArea.Utils.toPixel()

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Functions
  6. DiviArea.Utils.toPixel()
DiviArea.Utils.toPixel(value, unit, element)

Converts any CSS unit to pixels – at least any CSS unit that is available in Divi Areas.

Params

value
(int|float, required) The number to convert, e.g. 12 or 30.25
unit
(string, required) The unit which defines the value, e.g. “in” or “vw”.
element
(HTMLElement, optional) Optional. Element that defines the base for relative units like “em” or “%”.
Default: document.body

Returns

Integer that represents the pixel dimension of the input value.

Notes

No notes

Was this article helpful?

Related Articles