Reputation: 6029
I have products I display on my page, 8 in total.
I currently have this set up
<div class="row">
<div class="col-lg-12">
@foreach (var item in Model)
{
<div class="col-lg-4" style="margin-bottom:5%; position:relative">
<div class="boxTop"></div>
<div class="box">
<img src="/Content/Images/YogurtImages_280x135/@item.ImageName" width="280" height="135" alt="@item.ImageName" class="productMarginTop">
<br />
<p style="color: @item.ProductTextColor; font-size: @item.FontSize;" class="productTitle text-center">
@item.ProductTitle
</p>
<br />
<hr style="border: 1px solid @item.ProductTextColor" />
<h5 style="color: @item.ProductTextColor; font-size:19px" class="text-center" id="nutritionInfo" data-productid="@item.ProductId" data-colorcode="@item.ProductTextColor" data-productname="@item.ProductTitle">
NUTRITIONAL INFO <span class="glyphicon glyphicon-chevron-right"></span>
</h5>
<hr style="border: 1px solid @item.ProductTextColor" />
<h5 class="text-center" id="findStore">
<a data-toggle="collapse" data-parent="#accordion" href="#@item.ProductId" aria-expanded="true" aria-controls="@item.ProductId" style="color: @item.ProductTextColor;font-size:19px" class="text-center">
FIND A STORE <span class="glyphicon glyphicon-chevron-down"></span>
</a>
</h5>
<div id="@item.ProductId" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<p>
Content
</p>
<p>
More Content
</p>
</div>
</div>
<hr style="border: 1px solid @item.ProductTextColor" />
</div>
<div class="boxBtm"></div>
</div>
}
</div>
</div>
So 12 columns across and each product takes up 4 columns. Each product has its on accordion, so when find store is clicked the according expands showing details that stock that product. As I have eight products my current layout appears like this
First row : 3 products Second row : 3 products Third row : 2 products
As shown here
Now when I click on Find Store on the first or Second product either on the first or second row everything gets pushed to the right so it doesn't maintain its structure as shown here, as you can see the second product or the first row has been expanded causing the layout to be muddled up.
But if i click on the third product either on the first or second row the layout remains in tacked...
I'm slightly puzzled in to why this would be? can someone shed some knowledge on this?
Upvotes: 0
Views: 156
Reputation: 3286
First off having <div class="col-lg-12">
is redundant and can be removed. Second are all your products displayed in your 'foreach'? Because that would make your HTML structure look like this:
<div class="row">
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..1</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..2</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..3</div>
...
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..12</div>
</div>
But what you want is this:
<div class="row">
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..1</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..2</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..3</div>
</div>
<div class="row">
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..4</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..5</div>
<div class="col-lg-4" style="margin-bottom:5%; position:relative">..6</div>
</div>
That should fix your row being mis-aligned
Upvotes: 2