By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,648 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,648 IT Pros & Developers. It's quick & easy.

Simple Question (2 column layout)

P: n/a
I essentially have the standard two column layout, but I'm running
into a quirk I'm hoping someone can help with. I have one column
which is the main content (75%) of the screen and the remaining 25% is
reserved for "side" content.

The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

-me

------ code
#main
{
float: left;
width: 75%;
}

#side
{
}

and then the following HTML code
<html>

<div id="main">
let's say the text in this section takes up three lines on the screen.
</div>

<div id="side">
let's say this section has ten lines of text, the first three lines
will be just fine in this div, the other seven lines will wrap and
begin where text in the #main div would start. (instead of wrapping
to the start of the #side div)
</div>

</html>
------ end code
Jul 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
I should probably add that this was under IE6/Win

On 16 Apr 2004 21:16:48 -0700, Alfred wrote:
I essentially have the standard two column layout, but I'm running
into a quirk I'm hoping someone can help with. I have one column
which is the main content (75%) of the screen and the remaining 25% is
reserved for "side" content.

The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

-me

------ code
#main
{
float: left;
width: 75%;
}

#side
{
}

and then the following HTML code
<html>

<div id="main">
let's say the text in this section takes up three lines on the screen.
</div>

<div id="side">
let's say this section has ten lines of text, the first three lines
will be just fine in this div, the other seven lines will wrap and
begin where text in the #main div would start. (instead of wrapping
to the start of the #side div)
</div>

</html>
------ end code

Jul 20 '05 #2

P: n/a
I should probably add that this was under IE6/Win

On 16 Apr 2004 21:16:48 -0700, Alfred wrote:
I essentially have the standard two column layout, but I'm running
into a quirk I'm hoping someone can help with. I have one column
which is the main content (75%) of the screen and the remaining 25% is
reserved for "side" content.

The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

-me

------ code
#main
{
float: left;
width: 75%;
}

#side
{
}

and then the following HTML code
<html>

<div id="main">
let's say the text in this section takes up three lines on the screen.
</div>

<div id="side">
let's say this section has ten lines of text, the first three lines
will be just fine in this div, the other seven lines will wrap and
begin where text in the #main div would start. (instead of wrapping
to the start of the #side div)
</div>

</html>
------ end code

Jul 20 '05 #3

P: n/a

"Alfred" <om***@yahoo.com> wrote...
The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

-me

------ code
#main
{
float: left;
width: 75%;
}

#side
{
}

Stylesheet:

#main {
width: 75%;
}

#side {
float: right;
width: 25%;
}

html:

<div id="side">
content
</div>

<div id="main">
content
</div>

Putting the #side div first, which is floated to the right, will allow
the main content to flow around it. The #side content will not flow
outside of it's declared width.

Regards,
Jim

Jul 20 '05 #4

P: n/a

"Jim Roberts" wrote...
Stylesheet:

#main {
width: 75%;
}

[snip]


correction:

Either remove width: 75% from #main or add float: left;. Without this
modification, it did not work correctly in IE, although it seemed fine
in Mozilla.

#main {
width: 75%;
float: left;
}

or

#main {
/* other declarations */
}

Jim

Jul 20 '05 #5

P: n/a

"Alfred" <om***@yahoo.com> wrote...
The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

-me

------ code
#main
{
float: left;
width: 75%;
}

#side
{
}

Stylesheet:

#main {
width: 75%;
}

#side {
float: right;
width: 25%;
}

html:

<div id="side">
content
</div>

<div id="main">
content
</div>

Putting the #side div first, which is floated to the right, will allow
the main content to flow around it. The #side content will not flow
outside of it's declared width.

Regards,
Jim

Jul 20 '05 #6

P: n/a
Alfred wrote:
I essentially have the standard two column layout, but I'm running
into a quirk I'm hoping someone can help with. I have one column
which is the main content (75%) of the screen and the remaining 25% is
reserved for "side" content.

The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

[snip]

The "classic" answer to keeping things in columns is to give the non-floated
element a large margin on the side of the floated element. The margin should
be at least as wide as the width of the floated element.

The same technique works for avoiding superimposing onto absolutely-positioned
elements too, if you used that instead of float.

This "large margin" approach actually has a specific problem in the case of
floats, although I suspect that it won't matter much to you. If the viewport
becomes so narrow that the non-floated element drops below the floated one,
the non-floated element will still have that, now-inappropriate, large margin.
You need to experiment to see if it matter to you.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #7

P: n/a

"Jim Roberts" wrote...
Stylesheet:

#main {
width: 75%;
}

[snip]


correction:

Either remove width: 75% from #main or add float: left;. Without this
modification, it did not work correctly in IE, although it seemed fine
in Mozilla.

#main {
width: 75%;
float: left;
}

or

#main {
/* other declarations */
}

Jim

Jul 20 '05 #8

P: n/a
Alfred wrote:
I essentially have the standard two column layout, but I'm running
into a quirk I'm hoping someone can help with. I have one column
which is the main content (75%) of the screen and the remaining 25% is
reserved for "side" content.

The problem with my CSS is that if the main content's height is less
than the side content's height, the side content will wrap underneath
the main content instead of staying within the 25% bounds.

[snip]

The "classic" answer to keeping things in columns is to give the non-floated
element a large margin on the side of the floated element. The margin should
be at least as wide as the width of the floated element.

The same technique works for avoiding superimposing onto absolutely-positioned
elements too, if you used that instead of float.

This "large margin" approach actually has a specific problem in the case of
floats, although I suspect that it won't matter much to you. If the viewport
becomes so narrow that the non-floated element drops below the floated one,
the non-floated element will still have that, now-inappropriate, large margin.
You need to experiment to see if it matter to you.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #9

P: n/a
Thanks for your suggestions Jim. For some reason, only one of your
suggestions worked. (the one below. using IE6/Win in Standard mode) But
it worked, nonetheless. And with CSS, it almost seems best not to ask why.
:)

#main
{
float: left;
width: 75%;
}

#side
{
float: right;
width: 25%;
}
Jul 20 '05 #10

P: n/a
Thanks for your suggestions Jim. For some reason, only one of your
suggestions worked. (the one below. using IE6/Win in Standard mode) But
it worked, nonetheless. And with CSS, it almost seems best not to ask why.
:)

#main
{
float: left;
width: 75%;
}

#side
{
float: right;
width: 25%;
}
Jul 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.