Class Vw


public class Vw extends Units
CSS vw (viewport width) unit value.

The vw unit is equal to 1% of the width of the viewport. For example, if the viewport is 1200px wide, 1vw equals 12px. Viewport units are useful for creating responsive layouts that scale proportionally with the viewport size.

Usage:


 Units size = new Vw(100);  // Full viewport width
 element.setWidth(new Vw(50));  // Half viewport width
 element.setFontSize(new Vw(2));
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Vw

      public Vw(float value)
      Constructs a Vw unit with the specified value.
      Parameters:
      value - the vw value (percentage of viewport width)
  • Method Details

    • sizeToString

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