Does anyone know how Pinterest.com's layout works?

前端 未结 8 1146
时光说笑
时光说笑 2020-12-13 15:06

On http://pinterest.com/ there are \'pins\' ie

s of varying height but they all seem to render very well with no \'gaps\' or line breaks to interrupt the flow. Is
8条回答
  •  不思量自难忘°
    2020-12-13 15:16

    Check out JQuery Masonry, it will be the simplest way to achieve the layout you want. http://masonry.desandro.com/

    I did some reading of Pinterest's javascript a few months ago to figure this out myself. In short, they don't do it with CSS at all. They position all of their boxes/pins dynamically by iterating through them all, calculating the height, and dropping it at the bottom of whichever column that has the shortest height at the moment (adding that box's height to it). Basically, there's no trick to it, it's just Javascript.

提交回复
热议问题