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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -