如何计算网格宽度?

时间:2015-09-14 07:41:42

标签: javascript css grid

我想创建一个简单的JS脚本,它将循环遍历布局中的所有列,并计算其中一列是否可以是两列宽。

所以我的标准布局是三列,我将计算一行中三列中的一列是否可以是两列宽。如果它是连续的第一个或第二个,它应该在第一列或第二列中添加一个类,使列的列宽为两列。

我想出了以下内容,但现在我陷入其中:

// Grid calculation
    function gridCalc() {
        // Variables
        var container;
        var row;
        var item;

        container = document.getElementsByClassName('overview');

        container.row = document.getElementsByClassName('uniWrapper')[2];
        container.row.item = document.getElementsByClassName('infoItem');
        console.log(container.row.item);

        for (var i = container.row.item.length - 1; i >= 0; i++) {

        };

        // Get elements and store them in a var
        // Check the width of its container
        // If first or second in a row add class '2columns' random two one of the two

    } gridCalc();

我不知道如何启动此脚本。

0 个答案:

没有答案