How to get css3 multi-column count in Javascript

前端 未结 3 930
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 21:39

We\'re using the new css3 multi-column layout properties to get our text into newspaper columns. Each column gets a fixed width, and the column-count defaults to \"auto\", w

3条回答
  •  悲哀的现实
    2020-12-05 22:37

    The secret is to put a small marker at the end of the content. You can programmatically add an empty span:

    
    

    then grab the span using a jquery $("#mymarker") and get the "left" property. Divide that number by the width of the columns (adjusted for column-gap), and that will tell you what column this last element is in. Math.ceil() on the value and you have the column count.

提交回复
热议问题