473,396 Members | 1,813 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,396 software developers and data experts.

float sidebar

please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.

code below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLENew Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<STYLE>
* {
margin: 0;
padding: 0;
list-style: none;
}

body {
background: black;
}
#wrap {
width: 700px;
background: white;
margin: auto;
}
#head {
background: red;
}
#foot {
clear: both;
background: blue;
}
#main {
float: left;
}
#side {
background: green;
float: right;
width: 200px;
}
</STYLE>
</HEAD>

<BODY>
<div id="wrap">
<div id="head">
<h1>Title</h1>
</div>
<div id="main">
<h2>Content</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ut
purus non mauris luctus porttitor. Proin purus. Proin lobortis ligula
vel velit sollicitudin nonummy. Morbi vestibulum, lorem adipiscing
cursus mollis, ante mi sagittis nisl, vitae luctus est arcu at pede.
Vivamus egestas ullamcorper nunc. Nunc condimentum consequat dui.
Aliquam erat volutpat. Aliquam erat volutpat. Donec non turpis. Sed
facilisis. Nullam elementum, nisl sit amet aliquam malesuada, purus
sapien vulputate nibh, sit amet consectetuer ligula neque porttitor
enim.

Vivamus blandit mauris at sapien. Pellentesque tristique mauris a
arcu. In velit pede, consectetuer quis, mollis vel, pellentesque sit
amet, enim. Nunc in est. Vivamus imperdiet, nulla id fermentum blandit,
mauris orci dapibus odio, ut blandit tortor nisl nec eros. Aliquam
malesuada neque eu turpis. Morbi non arcu. Cras faucibus venenatis
nibh. Sed dolor nibh, tempor sit amet, aliquam vel, molestie ut, lacus.
Phasellus luctus. In lorem erat, faucibus porttitor, suscipit eu,
gravida sed, nunc. Aliquam faucibus feugiat nisl.

Phasellus nunc. Sed bibendum ligula quis dolor. Duis imperdiet, metus
vel facilisis vulputate, ipsum nulla dapibus mi, sed euismod velit
tellus eget nisi. Phasellus in augue. Nullam ullamcorper diam at urna.
Suspendisse aliquet, erat eget porttitor commodo, enim dolor
consectetuer elit, a tincidunt nisi lacus a libero. Morbi posuere odio
tempor risus. Cras non lacus. Nulla vitae urna. Nullam urna. Fusce
neque justo, luctus sed, ullamcorper facilisis, ultricies quis, ligula.
Cras ut turpis at ante mollis consequat. Pellentesque interdum purus.
Duis erat. Quisque laoreet sodales orci. Aliquam eu augue.

Nunc vitae odio. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. Vivamus mi velit, lacinia
vel, cursus nec, congue vel, urna. Pellentesque eget metus et arcu
aliquet ornare. Integer ac libero. Morbi tempor varius neque. Proin
quis dui. Nullam tempus egestas turpis. Donec vel ligula. Pellentesque
pharetra enim in odio. Maecenas ornare metus quis tortor. Integer
eleifend, pede faucibus condimentum cursus, elit pede fringilla lorem,
vitae tincidunt arcu lacus id purus. Etiam imperdiet tellus nec lacus.
Quisque laoreet nunc ut velit rutrum mattis.

Proin augue pede, tempor at, scelerisque eu, laoreet ullamcorper,
quam. Duis justo quam, nonummy ut, sollicitudin eu, dictum non, diam.
Nullam nec lorem eget lacus eleifend volutpat. Phasellus mollis ipsum
sed ante. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Quisque ullamcorper aliquam leo. Vestibulum et arcu. Sed pellentesque
pretium ipsum. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Etiam turpis ante, ultricies non,
porta ut, ultricies nec, dolor. Integer justo justo, condimentum ut,
laoreet sed, consectetuer ut, velit.</p>
</div>
<div id="side">
<h3>Title</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
<div id="foot">
Copyright &copy; Mark Bayazit 2006
</div>
</div>
</BODY>
</HTML>

thanks!

Aug 24 '06 #1
14 4949

Mark wrote:
please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.

code below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLENew Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<STYLE>
* {
margin: 0;
padding: 0;
list-style: none;
}

body {
background: black;
}
#wrap {
width: 700px;
background: white;
margin: auto;
}
#head {
background: red;
}
#foot {
clear: both;
background: blue;
}
#main {
float: left;
}
#side {
background: green;
float: right;
width: 200px;
}
</STYLE>
</HEAD>

<BODY>
<div id="wrap">
<div id="head">
<h1>Title</h1>
</div>
<div id="main">
<h2>Content</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla ut
purus non mauris luctus porttitor. Proin purus. Proin lobortis ligula
vel velit sollicitudin nonummy. Morbi vestibulum, lorem adipiscing
cursus mollis, ante mi sagittis nisl, vitae luctus est arcu at pede.
Vivamus egestas ullamcorper nunc. Nunc condimentum consequat dui.
Aliquam erat volutpat. Aliquam erat volutpat. Donec non turpis. Sed
facilisis. Nullam elementum, nisl sit amet aliquam malesuada, purus
sapien vulputate nibh, sit amet consectetuer ligula neque porttitor
enim.

Vivamus blandit mauris at sapien. Pellentesque tristique mauris a
arcu. In velit pede, consectetuer quis, mollis vel, pellentesque sit
amet, enim. Nunc in est. Vivamus imperdiet, nulla id fermentum blandit,
mauris orci dapibus odio, ut blandit tortor nisl nec eros. Aliquam
malesuada neque eu turpis. Morbi non arcu. Cras faucibus venenatis
nibh. Sed dolor nibh, tempor sit amet, aliquam vel, molestie ut, lacus.
Phasellus luctus. In lorem erat, faucibus porttitor, suscipit eu,
gravida sed, nunc. Aliquam faucibus feugiat nisl.

Phasellus nunc. Sed bibendum ligula quis dolor. Duis imperdiet, metus
vel facilisis vulputate, ipsum nulla dapibus mi, sed euismod velit
tellus eget nisi. Phasellus in augue. Nullam ullamcorper diam at urna.
Suspendisse aliquet, erat eget porttitor commodo, enim dolor
consectetuer elit, a tincidunt nisi lacus a libero. Morbi posuere odio
tempor risus. Cras non lacus. Nulla vitae urna. Nullam urna. Fusce
neque justo, luctus sed, ullamcorper facilisis, ultricies quis, ligula.
Cras ut turpis at ante mollis consequat. Pellentesque interdum purus.
Duis erat. Quisque laoreet sodales orci. Aliquam eu augue.

Nunc vitae odio. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. Vivamus mi velit, lacinia
vel, cursus nec, congue vel, urna. Pellentesque eget metus et arcu
aliquet ornare. Integer ac libero. Morbi tempor varius neque. Proin
quis dui. Nullam tempus egestas turpis. Donec vel ligula. Pellentesque
pharetra enim in odio. Maecenas ornare metus quis tortor. Integer
eleifend, pede faucibus condimentum cursus, elit pede fringilla lorem,
vitae tincidunt arcu lacus id purus. Etiam imperdiet tellus nec lacus.
Quisque laoreet nunc ut velit rutrum mattis.

Proin augue pede, tempor at, scelerisque eu, laoreet ullamcorper,
quam. Duis justo quam, nonummy ut, sollicitudin eu, dictum non, diam.
Nullam nec lorem eget lacus eleifend volutpat. Phasellus mollis ipsum
sed ante. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Quisque ullamcorper aliquam leo. Vestibulum et arcu. Sed pellentesque
pretium ipsum. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Etiam turpis ante, ultricies non,
porta ut, ultricies nec, dolor. Integer justo justo, condimentum ut,
laoreet sed, consectetuer ut, velit.</p>
</div>
<div id="side">
<h3>Title</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
<div id="foot">
Copyright &copy; Mark Bayazit 2006
</div>
</div>
</BODY>
</HTML>

thanks!
i guess i could have just uploaded the page instead of a picture of it

http://www.mnbayazit.com/misc/sample.html

Aug 24 '06 #2
Mark wrote:
Mark wrote:
>please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.
Place the markup for the side div immediately beneath the head div?

Louise
Aug 24 '06 #3

boclair wrote:
Mark wrote:
Mark wrote:
please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.

Place the markup for the side div immediately beneath the head div?

Louise
doesnt help. tried it already. just moves the sidebar above the main
content, and the content is moved down so that it can still fill the
entire width.

Aug 24 '06 #4
Els
Mark wrote:
please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.
[snip code]

Let div#side and div#main swap places. Put the float before the main
content.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Aug 24 '06 #5
Mark wrote:
boclair wrote:
>Mark wrote:
>>Mark wrote:
please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.
Place the markup for the side div immediately beneath the head div?

Louise

doesnt help. tried it already. just moves the sidebar above the main
content, and the content is moved down so that it can still fill the
entire width.
Just noticed that you have the content floated left via the main div.
Why? One float will not wrap another float and is the reason you are
seeing the content displayed this way.

Try
1.. comment out main div
2.. place markup for side div immediately below head div

Louise
Aug 24 '06 #6
boclair wrote:
Mark wrote:
>boclair wrote:
>>Mark wrote:
Mark wrote:
please view http://mnbayazit.com/misc/sample.gif
>
i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.
Place the markup for the side div immediately beneath the head div?

Louise

doesnt help. tried it already. just moves the sidebar above the main
content, and the content is moved down so that it can still fill the
entire width.

Just noticed that you have the content floated left via the main div.
Why? One float will not wrap another float and is the reason you are
seeing the content displayed this way.

Try
1.. comment out main div
2.. place markup for side div immediately below head div
Alternately, if the main div is necessary, place the side div markup
with the main div before any content as below

Louise

<div id="main">
<div id="side">
<h3>Title</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
<h2>Content</h2>
etc
Aug 24 '06 #7

boclair wrote:
Mark wrote:
boclair wrote:
Mark wrote:
Mark wrote:
please view http://mnbayazit.com/misc/sample.gif

i'm wondering how i can make the sidebar (green) float to the right of
the main text, without specifying the width of the main content
(because the sidebar is optional, i need the main content to fill the
space available). ie, the green sidebar should be right up against the
red header.
Place the markup for the side div immediately beneath the head div?

Louise
doesnt help. tried it already. just moves the sidebar above the main
content, and the content is moved down so that it can still fill the
entire width.

Just noticed that you have the content floated left via the main div.
Why? One float will not wrap another float and is the reason you are
seeing the content displayed this way.

Try
1.. comment out main div
2.. place markup for side div immediately below head div

Louise
well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.

if i could extend the sidebar down the page, it would fix the problem,
but height: 100%; doesnt do the trick.

Aug 24 '06 #8
Mark wrote:
boclair wrote:
>Mark wrote:
>>boclair wrote:
Mark wrote:
Mark wrote:
>please view http://mnbayazit.com/misc/sample.gif
>>
>i'm wondering how i can make the sidebar (green) float to the right of
>the main text, without specifying the width of the main content
>(because the sidebar is optional, i need the main content to fill the
>space available). ie, the green sidebar should be right up against the
>red header.
Place the markup for the side div immediately beneath the head div?

Louise
doesnt help. tried it already. just moves the sidebar above the main
content, and the content is moved down so that it can still fill the
entire width.
Just noticed that you have the content floated left via the main div.
Why? One float will not wrap another float and is the reason you are
seeing the content displayed this way.

Try
1.. comment out main div
2.. place markup for side div immediately below head div

Louise

well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.

if i could extend the sidebar down the page, it would fix the problem,
but height: 100%; doesnt do the trick.

Applying a 100% height rule to a floated element, irrespective of
content, begs the question, "100% of what?" There are certain hacks
that can be applied more or less reliably. Google on "height of float"

It is not allowable to float the main content div without declaring a
width, be it an absolute, or preferably, relative value.

Apart from this there are many ways to skin this cat. Time to do a
Google search on "two column layout"; plenty of examples that can be
adapted.

Commonly they involve applying a width equal to the width of the sidebar
to the width of right margin on the main div (floating the sidebar) or a
right border on the main div (absolutely positioning the sidebar).

If, however, the sidebar object (is the sidebar menu generated
programmatically?) may or may not have content, some sort of conditional
scripting will be involved. If the content is of zero length or is
null, the scripting not only not display the sidebar or apply zero
width, the margin width or border width rule on main div needs to be
reduced to zero. Easily do-able. If the sidebar contains links, it would
be unwise to do this client side. Off topic here.

A different layout might be more appropriate; a horizontal menubar
simplifies the problem and would leave the painting of the main content
independent of the inclusion of the menu. There also advantages if css
in not enabled.

Louise
Aug 25 '06 #9
Els
Mark wrote:
well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.
Give the content a margin-right that's wide enough for the width of
the sidebar, and it won't wrap around the sidebar anymore.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Aug 25 '06 #10

Els wrote:
Mark wrote:
well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.

Give the content a margin-right that's wide enough for the width of
the sidebar, and it won't wrap around the sidebar anymore.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
well..this defeats the purpose.
the whole idea was that when the sidebar is present the main content
will be smaller, but when the sidebar is absent, the main content will
take up the full width.

Sep 20 '06 #11
Els
Mark wrote:
Els wrote:
>Mark wrote:
>>well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.

Give the content a margin-right that's wide enough for the width of
the sidebar, and it won't wrap around the sidebar anymore.

well..this defeats the purpose.
the whole idea was that when the sidebar is present the main content
will be smaller, but when the sidebar is absent, the main content will
take up the full width.
You have a point :-)
(somehow overlooked your 'sidebar is optional')

In IE, it's easy: just give content "zoom:1;" and it will become a
block that sits next to the floated sidebar.

That doesn't work in Firefox though. Luckily, Firefox and Opera
understand "display:table-cell". Not tested in other browsers, but in
my local test case, #content{zoom:1;display:table-cell;} does what you
want in both IE5, IE7, Opera 8.54 and Firefox 1.5.06.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Sep 20 '06 #12

Els wrote:
Mark wrote:
Els wrote:
Mark wrote:

well, this worked..but now the main content wraps around the sidebar,
whereas i want it to make a nice neat column, stopping where the
sidebar does.

Give the content a margin-right that's wide enough for the width of
the sidebar, and it won't wrap around the sidebar anymore.
well..this defeats the purpose.
the whole idea was that when the sidebar is present the main content
will be smaller, but when the sidebar is absent, the main content will
take up the full width.

You have a point :-)
(somehow overlooked your 'sidebar is optional')

In IE, it's easy: just give content "zoom:1;" and it will become a
block that sits next to the floated sidebar.

That doesn't work in Firefox though. Luckily, Firefox and Opera
understand "display:table-cell". Not tested in other browsers, but in
my local test case, #content{zoom:1;display:table-cell;} does what you
want in both IE5, IE7, Opera 8.54 and Firefox 1.5.06.

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
hmm...interesting. i'll have to try this out.
thank you.

did you know i found this exact same thread on both

http://www.highdots.com/forums/casca...ar-186821.html
and
http://www.thescripts.com/forum/thre...7132-2-10.html

as well?? are they stealing content from google groups, or what's going
on?

Sep 25 '06 #13
Els
Mark wrote:
did you know i found this exact same thread on both

http://www.highdots.com/forums/casca...ar-186821.html
and
http://www.thescripts.com/forum/thre...7132-2-10.html

as well??
Those are only two of many.
are they stealing content from google groups, or what's going on?
No, they are not stealing content from Google Groups.
These sites, *and* Google Groups, are "stealing" content from Usenet.
You happen to use Google Groups, thinking it is the real thing. You
could have been using highdots or thescripts, thinking it is the
original. All of them are just displaying Usenet messages, while some
of these sites acknowledge it, and some don't. The ones that don't
acknowledge it I call thiefs, the ones that do, I call portals :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Sep 25 '06 #14

Els wrote:
Mark wrote:
did you know i found this exact same thread on both

http://www.highdots.com/forums/casca...ar-186821.html
and
http://www.thescripts.com/forum/thre...7132-2-10.html

as well??

Those are only two of many.
are they stealing content from google groups, or what's going on?

No, they are not stealing content from Google Groups.
These sites, *and* Google Groups, are "stealing" content from Usenet.
You happen to use Google Groups, thinking it is the real thing. You
could have been using highdots or thescripts, thinking it is the
original. All of them are just displaying Usenet messages, while some
of these sites acknowledge it, and some don't. The ones that don't
acknowledge it I call thiefs, the ones that do, I call portals :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
ahh.. so that's what this "usenet" thing is :p
i'll have to look into this, maybe i can use it on my site too... with
acknowledgement of course.

Sep 26 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Dan Rubin | last post by:
HI everyone, lurking for a long time here, since I can usually solve my own problems, but here is one I'm stumped by. I've got a valid XHTML 1.0 Transitional layout, and all the CSS is valid as...
0
by: Ryan | last post by:
I have a site at http://www.chancesend.com/news.html which displays fine in all PC browsers, but does an odd thing in IE for the Mac. In the div#main section, I have the main #content div...
0
by: Dean Speir | last post by:
Hoping that someone here can see the glitch I'm experiencing. I build a site for an organization in which a <TD> which recurs on most of the pages displays exactly as intended in IE, Netscape and...
10
by: Andrew | last post by:
I'm developing a site using CSS layout. One of the main divs contains the content, another contains the side bar. I want the content next to the sidebar so the content is floated left and the...
8
by: Brian Kendig | last post by:
I have a page which should have a "sidebar" to the left, and a "main" block of content to the right. I want to represent each block as a <div>, and I thought I could do this by having "float: left"...
2
by: Reiki Evolution | last post by:
Hi, Hopefully someone can help me here. I am recoding my web site. The original site was just in HTML but I am teaching myself CSS for the new site. My new site consists of three columns: a...
0
by: emanoelmelo | last post by:
Hi I'm having a problem to convert the Solemnity template to wordpress theme. This is the link: www.oficinapublicidade.com/assumpcao As you can see, in FF the sidebar is longer than the...
3
by: Bill | last post by:
If you type our web site directly in a browser, you get our web page. It has a top bar, a sidebar and a main text page in the middle. If you click on one of the menu choices across the top, it goes...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.