I have had this issue on numerous occasions and need to find a fix because it's causing me all sorts of grief. This problem includes HTML, CSS and JavaScript.
Essentially, I start off with an empty div .enrolledPlayers. I want to add a # amount of .player divs. I grab the width of .enrolledPlayers / 10, I use this determined size as the width and height of the the .player div.
This should give me 10 on a row, and wrap and do another 10 and so on...
Problem i'm having is the .player divs are slightly too large and for that reason wrap too early. I am adding pictures of the problem below. The weird thing is in Chrome when I click 'Toggle device toolbar' twice, it will fix the sizing as demonstrated in the pictures. Is their a reason for this? Or a fix? Thanks.
$(document).ready(function() {
let divWidth = $('.enrolledPlayers').width() / 10;
for(var i = 0; i < amount; i++) {
$('.enrolledPlayers').append('<div class="player" style="width: '+ divWidth +'px; height: '+ divWidth +'px; background: '+ getRandomColor() +';"></div>');
}
});
This is before I click the 'toggle device toolbar', show's the problem with the wrapping.
This is after I click the 'toggle device toolbar', this show's how it is supposed to look.