1 reply [Last post]
moltrex
moltrex's picture
Offline
newbie
Pascani
Last seen: 4 years 34 weeks ago
Pascani
Timezone: GMT+2
Joined: 2010-03-01
Posts: 1
Points: 2

Hey guys,

Can u help me on a question of mine. As the tittle says i want the parent div to take on auto the zise of the child div. I have made a poc to show u an example.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style>
* {
border:none;
margin:0px 0px 0px 0px;}
 
div {
border:none;
margin:0px 0px 0px 0px;}
 
#container {
margin:0 auto;
width:500px;
height:auto;
background-color:#CCCCCC;}
 
#left {
float:left;
width:250px;
height:auto;
background-color:#009966;}
 
</style>
</head>
 
<body>
<div id="container">
<div id="left">Lorem ipsum vide audire instructior ei eum, vel mollis sapientem assentior in. Oporteat adversarium definitionem eu pri, facilis facilisis ullamcorper an sea, his id elit tempor possim. Pri cu agam vitae vivendum, oportere vituperata neglegentur at sed, eius indoctum consequuntur sed ne. Sed an choro mentitum verterem, facer dictas explicari ut ius, nam eu unum animal ceteros. Cu eam latine bonorum reformidans, vim an utinam vivendo vivendum, molestie adipiscing cotidieque quo in.</div>
 
</div>
 
</body>
</html>

So if i set the height from #container to auto it won't take the size of child div and it's a bit frustating, in fact it won't show the #container.

So any ideeas on the subject ?

Regards Smile

wolfcry911
wolfcry911's picture
Offline
Guru
MA, USA
Last seen: 34 weeks 1 day ago
MA, USA
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3224
Points: 237

contain your floats