I am using a div whose dimensions are set using jquery, but i wish to show an image in that div and i also want the image to resize accordingly to fit in the div exactly.
How can this be done ???
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using jQuery to handle the parameters of a DIV element, then you could use the same method to handle the height/width of the image. You could try something like:
If you want to leave a small border, subtract a few pixels from both the height and the width and align the image centrally both horizontally and vertically.
Addon: Alternatively, you couls set CSS attributes to:
height: auto;
width: auto;
I had understood you wanted to use jQuery, my bad…