Reputation: 325
look, here are my html and css.
html:
<!DOCTYPE html>
<head>
<title>Untitled Document</title>
<link type="text/css" rel="stylesheet" href="stylesheets2.css" />
</head>
<body>
<div id="wrapper">
<div id="cont1"></div>
<div id="cont2"></div>
</div>
</body>
</html>
css:
*{
border:none;
}
#wrapper{
display:inline-block;
background-color:lightcyan;
position:absolute;
top:200px;
left:300px;
background-color:lightyellow;
border:1px solid green;
}
#cont1{
position:absolute;
width:100px;
height:50px;
background-color:red;
}
#cont2{
position:absolute;
width:50px;
height:100px;
background-color:red;
}
Upvotes: 3
Views: 8894
Reputation: 11318
This will fix problem, but i had to set position of inner elements to: relative.
*{
border:none;
}
#wrapper{
display:inline-block;
background-color:#ccc;
position:absolute;
top:200px;
left:300px;
border:1px solid green;
}
#cont1{
position:relative;
width:100px;
height:50px;
background-color:red;
}
#cont2{
position:relative;
width:50px;
height:100px;
margin-top:-50px;
background-color:red;
}
Fiddle: http://jsfiddle.net/9TZZ9/
Edit> more about problem -> absolute vs relative position width & height
Upvotes: 2