I have a div with a background image that is changed with Jquery. I want the div to resize itself when according to the size of its background image. If the background image is small than it shrinks to that size. Is this possible in any way?
If you can define the bg image sizes as variables in the JS then I suppose so but it’s not something that would be detected automatically.
Certainly not by CSS.
Or making the background image one specific width but not height so it wont stretch. will work too.
var bg=new Image;
var bgH =bg.height;
Or you could just do another way around, using background size to fit the div’s dimensions (background-size:contain);
Nevermind with this question. I found an alternative. Thank you guys anyways.
You must be logged in to reply to this topic.
*May or may not contain any actual "CSS" or "Tricks".