I have multiple images and i wnat to place all of them in a single line.How should i manipulate the width of images such that the sum of width of al images does not exceed the browser's width.??
what is padding.?? also the images are asymmetric...so if asssign the width of all the images to (window.width)/numImages.Some images get cut off...
Axesh Ajmera
2010-06-09 01:34:57
Oops. I didn't figure you'd have different widths. Silly me. Padding should actually be 'margin'.
Duracell
2010-06-09 01:47:34
A:
To be able to target them all at the same time give them all the same class or go from a containing id and get them by node name. After targeting them get their widths.
To get the widths into variables with jquery:
var $allImages = $('img.myImages');//all images need the same class
var allImagesW = $allImages.width() * $allImages.length;//you might want to use .outerWidth() to account for borders and padding, and .outerWidth(true) to include margins.
var windowW = $(window).width();
Dale
2010-06-09 01:32:19
This is very very close to a perfect solution. The only thing I would suggest is changing the while condition to "while (child)". As currently written, it won't act on the last image.
Ryan Kinal
2010-06-23 16:34:22