kristian_gr
asked on
div float width
I'm having a case where I'm having two, three or four div's inside a div, all with float left
I'd like the two, three or four divs to fill the main div with.
It's like a table where the widt is 100%, and you add colums.
Any ideas how to to this with divs?
I'd like the two, three or four divs to fill the main div with.
It's like a table where the widt is 100%, and you add colums.
Any ideas how to to this with divs?
<style type="text/css">
<!--
#main {
width: 350px;
background-color: #CCC;
}
.a {
float: left;
background-color: #3F9;
}
-->
</style>
</head>
<body>
<div id="main">
<div class="a">a</div>
<div class="a">b</div>
<!-- <div class="a">c</div> -->
</div>
You have to add widths to the floated divs. If #main is 350px then, assuming there's no padding or margins, the .a width needs to be 175px. Otherwise, the widths stay dynamic.
ASKER
well, in some cases it will be 175px, oher 100px depending on how many div's I've got at the moment.
Perhaps the correct anser to this is <table width="350px"><tr><td></td ><td></td> <!--<td></ td>--></tr ></table>?
Perhaps the correct anser to this is <table width="350px"><tr><td></td
You could use display:table-cell if you don't need to support IE6-7.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.