Msg#: 4328945 posted 11:20 pm on Jun 21, 2011 (gmt 0)
The CSS doesn't know how big the background is. Foreground, of course, would be no problem: unless you tell it otherwise, the container will expand to fit what it's holding. If only our clothes, garages and toolboxes could do the same :(
Msg#: 4328945 posted 11:29 pm on Jun 21, 2011 (gmt 0)
The range of image sizes is not completely out of my control, but it is too large of a range to simply set the div size to the highest possible value. Plus, sometimes there will be no background image at all, and the div simply needs to contain its contents.
Msg#: 4328945 posted 9:23 am on Jun 22, 2011 (gmt 0)
May be a background-image isn't the correct tool here and an absolutely positioned IMG (positioned behind other content), as in @pokra's solution would be better? This could be altered to simply:
Which doesn't rely on the actual page being rendered by PHP.
(2) Or, may be... load the image in a hidden IMG element (nothing is currently set as the background-image of the DIV container). Get the dimensions of this image (as above) and then set the dimensions AND background-image of your DIV container to the same as the IMG element. Not that this is possible though?