How to calculate the amount of flexbox items in a row?

后端 未结 11 1878
北荒
北荒 2020-12-04 12:12

A grid is implemented using the CSS flexbox. Example:

The number of rows in this example is 4 because I fixed the container width for demo purposes. But, in

11条回答
  •  悲&欢浪女
    2020-12-04 12:41

    If you're using Jquery and are confident that your grid objects are vertically aligned, this could do the trick..

    I didnt test it, but it should work (by counting the columns)

    function countColumns(){
       var objects = $(".grid-object"); // choose a unique class name here
       var columns = []
    
       for(var i=0;i

提交回复
热议问题