Check out the code snippet below:
<div id="container">
<div class="b">test1</div>
<div class="b">test2</div>
<div class="b">test3</div>
<div class="b">test4</div>
<div class="b">test5</div>
<div class="b">test6</div>
</div>
CSS
.b {
display:inline-block;
position: relative;
margin: 2px;
float:left;
width: calc(16.7% - 10px);
height:400px;
background-color: white;
border: 1px solid black;
}
http://jsfiddle.net/329vcLLc/ works perfectly, displaying 5 columns as desired.
I need to loop through an array to create div elements based on the array length. I was thinking of using the append()
function. What do you suggest? Also, how can I dynamically set the width property for each div based on the number of columns?
Any suggestions or ideas?