Class Em


public class Em extends Units
CSS em unit value.

The em unit is relative to the font-size of the element. If the element has a font-size of 16px, then 1em equals 16px, 2em equals 32px, etc. Em units are particularly useful for creating scalable layouts that adapt to font size changes.

Usage:


 Units size = new Em(1.5f);
 element.setPadding(new Em(1));
 element.setMargin(new Em(2.5f));
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Em

      public Em(float value)
      Constructs an Em unit with the specified value.
      Parameters:
      value - the em value
  • Method Details

    • sizeToString

      public String sizeToString()
      Returns the CSS string representation of this em value.
      Specified by:
      sizeToString in class Units
      Returns:
      the CSS value string (e.g., "1.5em")