javascript - How does Pinterest keep their image height proportionate -
i want load in bunch of random images (of varying widths , heights) column. column have fixed width, , height have cropped off proportionally keep image in it's original height width ratio. (similar how pinterest structures boards.)
anyone know how accomplished javascript or jquery?
you can use css:
img.autosize { width: 500px; /*specify width here*/ height: auto; }
this keep images in site fixed width (use max-width in case don't want of them exact same width) , height adjust accordingly maintain aspect ratio.
of course, if want use javascript or jquery, can set css properties in script. hassle-free way it.
Comments
Post a Comment