Reputation: 5887
I have a div that I would like to have a border and background-color, but the container has collapsed because everything is floated.
This can be see at http://jsfiddle.net/5DNFs/
How do I get the <div class="due-total">
to have the border and background-color?
Upvotes: 0
Views: 99
Reputation: 2787
You need to force a new formatting context or use a non-floating element to clear the floats (AKA. clearfix) .
But it looks like you should be using a table for this data anyway.
Upvotes: 0
Reputation: 1756
Try adding overflow to each of the floated containers:
overflow: auto
This solves the collapsing issue. It looks to me like your styling is wrong too with the floats. Clearing floats will help too.
Upvotes: 0
Reputation: 10246
You can add div as child of due-total, here is the example:
.invoice-totals .due-total > div {
border: 1px solid #DDD;
background-color: #CCC;
padding: 5px;
}
Alternative:
.invoice-totals .due-total {
float: left;
border: 1px solid #DDD;
background-color: #CCC;
padding: 5px;
}
Upvotes: 1
Reputation: 157314
Clear your floats : My Fiddle
Note: Just changed border color so that you can see, you can change it to whatever you want
HTML
<div class="invoice-totals">
<div class="total">
<div class="label">TOTAL</div>
<div class="value">133.00</div>
</div>
<div class="paid-total">
<div class="label">Payments</div>
<div class="value">0.00</div>
<div style="clear: both;"></div>
</div>
<div class="due-total">
<div class="label">AMOUNT DUE</div>
<div class="value">133.00</div>
<div style="clear: both;"></div>
</div>
</div>
Upvotes: 3