/    Sign up×
Community /Pin to ProfileBookmark

DIV won’t wrap around other DIVs

I’m trying to put two divs inside of one. The outer most div is supposed to provide a background for the two interior divs. Here is what the code looks like (I’ve shortened it, not including all tags, to give you the jist of it):

[CODE]<div class=”outer”>
<div class=”inner1″><p>DIV 1</p></div>
<div class=”inner2″><p>DIV 2</p></div>
</div>

#outter {
width: 500px;
background-color: #FFFFFF;
}
#inner1 {
width: 500px;
height: 300px;
clear: both;
}
#inner1 {
width: 500px;
height: 200px;
clear: both;
}[/CODE]

…problem is, I want the ‘outer’ div to extend down with the ‘inner1’ and ‘inner2’ divs, but it won’t – it insists on staying at the top. I tried replacing the ‘div’ tags of the ‘outer’ div with proper table tags, and it worked, but I want to figure out how to make this work with divs. What CSS properties do I need to add to the CSS? Or what different scheme should I use?

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@CreativeCozzaMar 19.2007 — I have done a simular thing for a website I am working on at the moment, 1 outer div to control all the content, and two seperate ones to control each section of my page.

Take a look at my codes, maybe this will help you...

[CODE]
<BODY>

<!-- This controls the whole of my content -->
<DIV id="contents">

<!-- This controls the left side of the 'book'. -->
<DIV id="left_side">
<H4>
Content for left side
</H4>
</DIV>


<!-- This controls the right side of the 'book' -->
<DIV id="right_side">
<H4>
Content for right side
</H4>
</DIV>

<!-- This ends my contents div -->
</DIV>

</BODY>

[/CODE]


The Z-index is the number of the layer I am using, you need to change these ?
[CODE]

#contents {
width: 690px;
margin: 70px auto 0;
margin-top: 200px;
z-index: 7;
}

#left_side {
float: left;
width: 340px;
margin-left: -2%
margin-top: -13%;
z-index: 6;
}

#right_side {
margin-left: 380px;
margin-top: 5%;
z-index: 5;
}

[/CODE]


It's hard to look at somebody's code and try to figure it out, I really have to sit and play with it myself. I hope this helps! ?
Copy linkTweet thisAlerts:
@TheBearMayMar 19.2007 — A few typos in what you supplied....

<i>
</i>&lt;div class="outer"&gt;
&lt;div class="inner1"&gt;&lt;p&gt;DIV 1&lt;/p&gt;&lt;/div&gt;
&lt;div class="inner2"&gt;&lt;p&gt;DIV 2&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;

.outer {
width: 500px;
background-color: #FFFFFF;
}
.inner1 {
width: 500px;
height: 300px;
clear: both;
}
.inner1 {
width: 500px;
height: 200px;
clear: both;
}
×

Success!

Help @walman05 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...