Is there a method that allows for the incorporation of pixel width paddings or margins in a fluid column design, without requiring additional html markup?
To better explain, consider a basic html/css layout like this:
<style>
.cont{width:500px;height:200px;border:1px solid black;}
.col{float:left;}
#foo{background-color:blue;width:10%;}
#bar{background-color:yellow;width:30%;}
#baz{background-color:red;width:60%;}
</style>
<div class="cont">
<div class="col" id="foo">Foo</div>
<div class="col" id="bar">Bar</div>
<div class="col" id="baz">Baz</div>
</div>
This setup works fine (ignoring any potential display bugs). However, once padding of 10px is added to the col
class, the floats no longer align correctly. The same issue arises if a 3px border is applied to the col
class. While negative margin techniques can counteract the box model's added pixels, they do not adjust the <div>
width. Essentially, the goal is to maintain a 10% width with 10px of that percentage dedicated to padding (or margin).