473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Simple Question (2 column layout)

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
10 2067
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
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

"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

"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

"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
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

"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Doug McCrae | last post by:
http://www.btinternet.com/~doug.mccrae/go4learning/index.html As it says in the subject, a two column layout (plus header and footer boxes). I feel the left column really needs to be fixed width...
0
by: Alfred | last post by:
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...
4
by: Stian Lund | last post by:
Hi, I'm trying to create a 2 column layout with a footer on the bottom, where the (fixed-width) sidebar follows the content in the code, while showing on the left hand side of the content. The...
3
by: Paul Burke | last post by:
Hi all I am hoping someone can help with a 2 column layout. It works ok in IE, but the second column (right) appears below the first column when viewed in FF or NS. Here is the url...
16
by: Dan V. | last post by:
How do you do a css 2 column layout with header and footer, with the 2nd column auto-stretching so entire page looks good for 800 x 600 resolution as min. and 1024 x 768 resolution as a max? ...
15
by: Tamblyne | last post by:
This problem has got to have a simple solution and I can't be the first person who has ever handled it. Perhaps Google is no help because I'm not using the right terms? (I did find one post...
10
by: Philipp E. Imhof | last post by:
Hi! I am experiencing a problem with a two-column layout -- apparently I am not the first person, but the solutions I found in GG did not give me what I was looking for. The page should be as...
3
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. I seek confirmation for the reasons behind a margin-related behavior I have observed. I have set up a simple test page to illustrate the issue. The page shows a very simple 2-column...
3
by: Mark | last post by:
Hi all I would like to create a simple two column layout - navigation on the left and content on the right. I would like the columns to have a fluid width so they can grow and shrink according...
1
Death Slaught
by: Death Slaught | last post by:
I will be showing you how to make a very simple but effective three column layout. First we will begin with the HTML, or structure, of our three column layout. <!DOCTYPE html PUBLIC...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.