Class BackgroundPositionHelper

java.lang.Object
dev.jcputney.mjml.util.BackgroundPositionHelper

public final class BackgroundPositionHelper extends Object
Normalizes CSS background-position values to "x y" format. Shared by MjSection and MjWrapper.
  • Method Details

    • normalize

      public static String normalize(String pos)
      Normalizes background position to "x y" format. Swaps y-x order: "top center" becomes "center top". Single values get "center" appended: "50%" becomes "50% center". Null/empty returns "center top".
      Parameters:
      pos - the background position string to normalize, may be null or empty
      Returns:
      the normalized background position in "x y" format
    • isYValue

      public static boolean isYValue(String val)
      Checks whether the given value is a vertical (y-axis) position keyword.
      Parameters:
      val - the CSS position value to check
      Returns:
      true if the value is "top" or "bottom", false otherwise
    • isXValue

      public static boolean isXValue(String val)
      Checks whether the given value is a horizontal (x-axis) position keyword.
      Parameters:
      val - the CSS position value to check
      Returns:
      true if the value is "left", "right", or "center", false otherwise