Class BackgroundCssHelper
java.lang.Object
dev.jcputney.mjml.util.BackgroundCssHelper
Builds CSS background-related style maps for sections and wrappers. Eliminates duplication
between MjSection and MjWrapper.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilds the CSS background shorthand for a component with background image.buildBgImageDivStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize, int containerWidth) Builds style map for outer div of a section/wrapper with background image.buildBgImageTableStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize) Builds style map for inner table of a section/wrapper with background image.
-
Method Details
-
buildBackgroundCss
public static String buildBackgroundCss(String bgColor, String bgUrl, String bgPosition, String bgSize, String bgRepeat) Builds the CSS background shorthand for a component with background image. Format: "#color url('...') position / size repeat"- Parameters:
bgColor- the background color value, ornull/empty if nonebgUrl- the background image URLbgPosition- the background position value (e.g. "center top")bgSize- the background size value (e.g. "auto", "cover")bgRepeat- the background repeat value (e.g. "repeat", "no-repeat")- Returns:
- the CSS background shorthand string
-
buildBgImageDivStyleMap
public static Map<String,String> buildBgImageDivStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize, int containerWidth) Builds style map for outer div of a section/wrapper with background image.- Parameters:
bgCss- the CSS background shorthand valuebgPosition- the background position valuebgRepeat- the background repeat valuebgSize- the background size valuecontainerWidth- the container width in pixels- Returns:
- a map of CSS property names to values for the background image div
-
buildBgImageTableStyleMap
public static Map<String,String> buildBgImageTableStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize) Builds style map for inner table of a section/wrapper with background image.- Parameters:
bgCss- the CSS background shorthand valuebgPosition- the background position valuebgRepeat- the background repeat valuebgSize- the background size value- Returns:
- a map of CSS property names to values for the background image table
-