Class Vh


public class Vh extends Units
CSS vh (viewport height) unit value.

The vh unit is equal to 1% of the height of the viewport. For example, if the viewport is 900px tall, 1vh equals 9px. Viewport units are useful for creating full-screen layouts that adapt to different screen sizes.

Usage:


 Units size = new Vh(100);  // Full viewport height
 element.setHeight(new Vh(50));  // Half viewport height
 element.setMinHeight(new Vh(80));
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Vh

      public Vh(float value)
      Constructs a Vh unit with the specified value.
      Parameters:
      value - the vh value (percentage of viewport height)
  • Method Details

    • sizeToString

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