I've been struggling to adjust the width of the div assigned with the colors class, whether in percentage or pixels.
var colors = ["RED", "GREEN", "BLUE", "YELLOW", "PURPLE"];
for (var h = 0; h <= 4; h++) {
for (var i = 0; i <= colors.length - 1; i++) {
var element = "<div class='colors' id='color" + i + "'>" + colors[i] + "</div>";
var sample = "sahdkj";
$('#gameContainer').append(element);
};
$('#gameContainer').append("<br/><br/>");
}
body {
margin: 10px;
}
.container {
border: 2px solid #e7e7e7;
border-radius: 3px;
width: 407px;
}
.colors {
display: inline;
border: 1px solid black;
width: 20%;
position: relative;
top: 10px;
bottom: 10px;
margin: 10px;
padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="container" id="gameContainer">
</div>
</body>