Monday, October 4, 2010

Css Tutorial : Adding Child Divs

The container div can act as parent to child divs. Here, an ID holds a reusable class called box:
<div id="container">
<p>This is our content area.</p>
<div class="box">
<p>I'm in a box!</p>
</div>
<div class="box">
<p>I'm also in a box!</p>
</div>
</div>
The CSS rules for the box class are almost the same as that for the parent container, except
for the background color, which will appear by default. Note that, as no set width is defined for
the box, it will stretch to fit whatever contains it, be that another div or the browser window:

/* Define styling of our reusable box */
.box {
margin: 10px;
padding: 20px;
border: 1px solid #000;
}

No comments:

Post a Comment