Bootstrap media object cannot align properly -
i using bootstrap 3 media objects , have code here dynamically want have 4 columns in 1 row,but problem last row have spaces inbetween second row. here code.
//content.php
for(var i=0;i<12;i++){ mymdedia+= '<div class="media col-sm-3">'+ '<div class="media-left">'+ '<a href="#">'+ '<img src=".....">'+ '</a>'+ '</div>'+ '<div class="media-body">'+ '<h4 class="media-heading">'john doe'</h4>'+ '<p>live: '+data[i].address+'</p>'+ '</div>'+ '</div>'; } $('#mycontainer').append(mymdedia);
//index.php
<div class="someclass"> <div class="row" id="mycontainer"> </div> </div>
and result looks like
i believe placing media objects in 1 row ... , don't fit.
in every row you've opened ( <div class='row'>...</div>
) can place 4 <div class='media col-sm-3'></div>
... because each col size = 3 ... ( 4x3 = 12 )
so in for
loop, after each 4 media objects - should close current row div , create new <div class='row'>
...
see plunker: http://plnkr.co/edit/bja3qdbkcymdwhw809gp?p=preview
right after loop:
for(var i=0;i<12;i++){ if ( && % 4 == 0 ) mymdedia += '</div><div class="row">'; // close row , create new 1 ... original code ... } mymdedia += '</div>' // close last row outside loop ...
Comments
Post a Comment