Class Ch


public class Ch extends Units
CSS ch (character) unit value.

The ch unit is equal to the width of the "0" (zero) character in the element's font. This unit is particularly useful for sizing elements based on the number of characters they should contain, especially for monospace fonts.

Usage:


 Units size = new Ch(40);  // Width for approximately 40 characters
 element.setWidth(new Ch(60));
 element.setMaxWidth(new Ch(80));
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Ch

      public Ch(float value)
      Constructs a Ch unit with the specified value.
      Parameters:
      value - the ch value (width of "0" character)
  • Method Details

    • sizeToString

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