Forum Moderators: not2easy
I'm trying to create a page with a white div inside a colored div with the colored div forming a border around the white div. I've set the height and width of the outer div, and I thought I could set the height and width of the inner div to 100% and give the inner div a margin to get that border. BUT on Firefox the inner div seems to be exactly the same width as the outer div, so the the left margin pushes it over and the right side of the inner div spills over outside of the inner div. Similar problem with the bottom. Perhaps that's what I should expect if I really understood the standards. Is there a better way to get the inner div to completely fill (width and height) the area within the outer div except set in by the margins of the inner div?
I've tried using padding on the outer div instead of margins on the inner div, but same problem. I know I can set a fixed (px) width and height of the inner div, but I want this to resize if I change just the dimensions of the outer div.
Some of my code in case it helps:
#prefsoutline
{
width: 570px;
height: 620px;
position: relative;
background-color: #DAE2ED;
border: 1px solid #A1B9D0;
}
.prefspane
{
margin: 10px;
background-color: #FFFFFF;
height: 100%;
width: 100%;
}
<-snip->
<div id="prefsoutline">
<div class="prefspane">
Prefs Here!
</div>
</div>
I thought I was finally getting a grip on CSS, but maybe I'm missing someting. BTW, it works the way I had hoped it would on IE, but that kind of comment seems to usually get a response that I'm doing something wrong and IE only works because IE is wrong too. Any help towards doing it right will be greatly appreciated!
-Tim
You said you tried using padding on the parent, but it's working for me:
#prefsoutline{
width:570px;
height:620px;
background-color:#dae2ed;
border:1px solid #a1b9d0;
padding:10px;
position:relative;
}
.prefspane{
background-color:#fff;
height:100%;
width:100%;
}
I want an outer-most div to define the overall size of the other divs I'll describe as well as some others I'll leave out. I want the middle div to give me that frame around the inner-most div. With padding of the middle div, the middle div and inner-most divs are working correctly together. The real problem is that I want the middle div to fill the outer-most div but with its padding and width 100% it overflows the outer-most div.
Here's the more complete code:
#prefsframe
{
width: 570px;
height: 620px;
border: 1px solid red;
padding: 20px 0px 0px 0px;
position: absolute;
left: 150px;
top: 40px;
}
#prefsoutline
{
position: relative;
width: 100%;
height: 100%;
background-color: #DAE2ED;
padding: 10px;
border: 1px solid #A1B9D0;
}
.prefspane
{
background-color: #FFFFFF;
height: 100%;
width: 100%
}
<snip>
<div id="prefsframe">
<div id="prefsoutline">
<div class="prefspane">
Prefs Here!
</div>
</div>
</div>
BTW, the padding at the top of the outer-most div is to leave space for some tabs.
It has occured to me that I might get this to work by defining the size of the inner-most div and building up from there, but I'm not sure that will be as convenient for laying out the whole page.
Thanks,
Tim
Alternatively, since you're using a fixed width and height (in pixels), you could just create the whole of this double border affect using a single background on a single padded div.