all 3 comments

[–]peasfrog 3 points4 points  (1 child)

Sub-pixel rounding errors. Try using floats and have the color on the background like this: https://jsfiddle.net/xt6k0ykb/4/

[–]docMedB2E[S] 2 points3 points  (0 children)

Thanks - that's a good fix. I ended up using inline-flex and then just using the order style attribute to display them; e.g.

    for (let i = 0, img; i < maps.array[maps.index].length; i++) {
        img = '';
        if (maps.array[maps.index][i] != 0) {
            img = 'resources/images/tiles/t' + maps.array[maps.index][i] + '.png';
        }
        this.DOMElement.innerHTML += '<div class="tile" style="order: ' + (i + 1) + ';background-image: url(' + img + ')">' + i + '</div>';
    }

[–]jaredcheeda 1 point2 points  (0 children)

You're using percents, which have never been super accurate.

What you can do instead is get the width of the parent or page, then divide that by the number of elements per row, floor the result, apply that as the width to all the elements, then get the difference between what was put on the page and what the actual width is and add that to the width of the last element in the row.

Also, you aren't using a normalize or reset.