1 Reply Latest reply on Feb 2, 2015 5:44 AM by resdesign

    Element change its size according to dynamicaly loaded image

    Zoze Level 2



      I have an element "rectangle" with size 50x50px, that is loading images dynamically.


      The size images of the images that is loading varies , eg, 128x260, or 72x155 etc.



      I want the $("rectangle") to have the same size as the dynamic image. How can i do that?


      the image is loaded as:

                sym.$("rectangle").css({ "background-size": "auto", "background-repeat": "no-repeat", "background-image": "url(" + item.image + ")" });



      but it is wrong as the image size isn't the original, It is scaled inside to $("rectangle") and it's size is 50x50.


      I want to keep the original size of the image and the $("rectangle") change its dimensions to be the same as the image.