Currently JavaFX uses the image's intrinsic size if no height value is specified (or auto). This implementation does meet the CSS 3 specification on background size in (Section 3.9 of http://www.w3.org/TR/css3-background/). However it is better to support "auto" by using the image's intrinsic ratio and the size of the other dimension, and we can file a new feature request to do this. As for now, there is a relative easy way to what user want, ie. specify both width and height dimension. (See RT-14454 for details)
Section 3.9:
"The first value gives the width of the corresponding image, the second value its height. If only one value is given the second is assumed to be 'auto'.
A percentage is relative to the background positioning area.
An 'auto' value for one dimension is resolved by using the image's intrinsic ratio and the size of the other dimension, or failing that, using the image's intrinsic size, or failing that, treating it as 100%.
If both values are 'auto' then the intrinsic width and/or height of the image should be used, if any. If the image has neither an intrinsic width nor an intrinsic height, its size is determined as for 'contain'.
Negative values are not allowed."
Section 3.9:
"The first value gives the width of the corresponding image, the second value its height. If only one value is given the second is assumed to be 'auto'.
A percentage is relative to the background positioning area.
An 'auto' value for one dimension is resolved by using the image's intrinsic ratio and the size of the other dimension, or failing that, using the image's intrinsic size, or failing that, treating it as 100%.
If both values are 'auto' then the intrinsic width and/or height of the image should be used, if any. If the image has neither an intrinsic width nor an intrinsic height, its size is determined as for 'contain'.
Negative values are not allowed."
- relates to
-
JDK-8114333 Region: css "-fx-background-size" with percents doesn't work properly with background images
- Closed