Class Percent

java.lang.Object
com.oorian.css.units.Units
com.oorian.css.units.Percent

public class Percent extends Units
CSS percent (%) unit value.

The percent unit is a relative-length unit that represents a percentage of another value, typically the parent element's corresponding property. For example, width: 50% means 50% of the parent element's width. Percentages are fundamental for creating responsive, flexible layouts.

Usage:


 Units size = new Percent(50);
 element.setWidth(new Percent(100));
 element.setPadding(new Percent(10));
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Percent

      public Percent(int value)
      Constructs a Percent unit with the specified value.
      Parameters:
      value - the percent value (0-100 or beyond)
  • Method Details

    • sizeToString

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