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

fixed width, 2 column CSS layout problem

P: n/a
Ed
The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html

I trying to get the yellow sidebar to go in the white area to the right
of the green content area and between the blue header and footer. Does
anyone know how to do?

I know I can add float: left; to the content div and it sort of works,
but it doesn't seem right either. In this case the content div and the
side bar div will no longer stay in their container, the page div,
instead they will overlap the bottom of their container.

I've read several similar threads on this newsgroup and still can't
figure it out. I've googled for a solution too, and I've found several
examples CSS layouts, but none that are similar enough to what I'm
attempting. I know of several sites that use a similar layout and I've
tried stripping them down to the bare bones layout, but each time I've
tried I've screw it up.

Aug 30 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Ed wrote:
The page I'm working on is at
http://www.coldpizzasoftware.com/temp/layout.html

I trying to get the yellow sidebar to go in the white area to the right
of the green content area and between the blue header and footer. Does
anyone know how to do?

Replace:
#sidebar {
background-color: lightyellow;
border: thin solid gray;
position: absolute;
left: auto;
right:0;
width: 210px;
}

With:
#sidebar {
background-color: lightyellow;
border: thin solid gray;
width: 210px;
float: right;
}

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Aug 30 '05 #2

P: n/a
On Tue, 30 Aug 2005 15:24:42 -0700, Ed wrote:
The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html

I trying to get the yellow sidebar to go in the white area to the right
of the green content area and between the blue header and footer. Does
anyone know how to do?

I know I can add float: left; to the content div and it sort of works,
but it doesn't seem right either. In this case the content div and the
side bar div will no longer stay in their container, the page div,
instead they will overlap the bottom of their container.

I've read several similar threads on this newsgroup and still can't
figure it out. I've googled for a solution too, and I've found several
examples CSS layouts, but none that are similar enough to what I'm
attempting. I know of several sites that use a similar layout and I've
tried stripping them down to the bare bones layout, but each time I've
tried I've screw it up.


Take a look at http://www.positioniseverything.net/ they might be able to
help!
Aug 31 '05 #3

P: n/a
On Tue, 30 Aug 2005 15:24:42 -0700, Ed wrote:
The page I'm working on is at http://www.coldpizzasoftware.com/temp/layout.html

I trying to get the yellow sidebar to go in the white area to the right
of the green content area and between the blue header and footer. Does
anyone know how to do?

I know I can add float: left; to the content div and it sort of works,
but it doesn't seem right either. In this case the content div and the
side bar div will no longer stay in their container, the page div,
instead they will overlap the bottom of their container.

I've read several similar threads on this newsgroup and still can't
figure it out. I've googled for a solution too, and I've found several
examples CSS layouts, but none that are similar enough to what I'm
attempting. I know of several sites that use a similar layout and I've
tried stripping them down to the bare bones layout, but each time I've
tried I've screw it up.


It was bugging me so try this, let me know if it is what you were after

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title></title>
<link rel="stylesheet"
href="testdiv.css"
type="text/css">
<meta name="Generator"
content="TextPad 4.7">
<meta name="Author"
content="">
<meta name="Keywords"
content="?">
<meta name="Description"
content="?">
<meta http-equiv="content-type"
content="text/html; charset=us-ascii">
<style type="text/css">

#page{
background-color:#fff ;
width: 760px;
margin: 20px auto;
}
#header{
background-color:#6cf ;
width:100%;
float: left;
}
#footer{
background-color:#6cf ;
width: 100%;
position: relative;
float: left;
}
#content{
margin: 0 30% 0 0;
border: 1px solid #000;
padding: 0 10px 10px ;
}
#sidebar{
width: 30%;
background-color: #ff9;
float: right;
}
</style>
</head>

<body>
<div id="page">
<div id="header">
<h1>The page title here</h1>
</div>

<div id="sidebar">
<ul>
<li>Item 1</li>

<li>Item 2</li>

<li>Item 3</li>
</ul>
</div>

<div id="content">
<p>this is the content box that goes on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on and on and on and on and on and on and on
and on and on</p>
</div>

<div id="footer">
<p>This is the footer and stuff</p>
</div>
</div>
</body>
</html>
Aug 31 '05 #4

P: n/a
Ed
On 2005-08-30 16:20:10 -0700, Jim Moe <jm***************@sohnen-moe.com> said:
#sidebar {
background-color: lightyellow;
border: thin solid gray;
width: 210px;
float: right;
}


That, for some reason, doesn't work unless I put the sidebar div before
the content div in the html and I don't want to do that. The solution
is definitely to use float though, so thanks.

Aug 31 '05 #5

P: n/a
Ed
On 2005-08-31 04:52:56 -0700, Rincewind <th***********@hotmail.com> said:
It was bugging me so try this, let me know if it is what you were after


That's is what I'm after. I was trying to avoid having to put the
sidebar before the content in the HTML, but if I must then I must. It
seems strange to me that this would make any difference at all, but it
makes all the difference. Thank you.

As a side question does anyone know why CSS doesn't allow you to do
something like the following:

#sidebar {
top: #content.top;
left: #content.right;
}

That makes infinitely more scene to me and would simplify most all
layouts IMHO.

Aug 31 '05 #6

P: n/a
Shawn Wilson wrote:
What you're trying to accomplish is called a 'faux' layout


Who besides you calls it 'faux'? I have never heard of such a thing, and
I've been around here for a long time. Regardless, a JavaScript solution
is no solution, at least for many people. In most cases, JS isn't
necessary anyway.

And quit posting attachments, especially binaries. This is a text-only
newsgroup.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Sep 1 '05 #7

P: n/a
Ed wrote:

That, for some reason, doesn't work unless I put the sidebar div before
the content div in the html and I don't want to do that.

Well, yes, of course. "float" is the equivalent of "align" for <img>
and causes an element to act in a similar manner.
What is wrong with correctly ordering the elements to achieve your
target design?

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 1 '05 #8

P: n/a
Ed
On 2005-09-01 00:20:21 -0700, Jim Moe <jm***************@sohnen-moe.com> said:
Ed wrote:

That, for some reason, doesn't work unless I put the sidebar div before
the content div in the html and I don't want to do that.

What is wrong with correctly ordering the elements to achieve your
target design?

Well, nothing, that is, if all I'm trying to achieve is a visually
appealing page. It's, however, my understanding that the point of
designing with XHTML and CSS is so that you can layout the HTML
semantically and then apply a style sheet to make it look great.

Since I'm of the opinion that the content of the page is significantly
more important than the navigation, I have the the content to the left
of the navigation and semantically the the content should come before
the navigation. Of course this assumes the use of a western (left to
right) language. Should my site ever need to support a right to left
language, I would apply a separate style sheet, so that the content
would be on the right side and navigation on the left, thus adhering to
the conventions of that language. In the HTML the semantic order would
be preserved, so that the content came before the navigation.

Undoubtedly, the particular website I'm working on working on will
never need to support this, but I'd like to get in the habit of doing
things, in my opinion, correctly.

Thanks to Rincewind's and your reply I have my layout working both
visually and semantically, with only one minor annoyance. If I can't
figure it out soon, I'll most likely chime in with a new questions.
Sep 1 '05 #9

P: n/a
Ed wrote:

That, for some reason, doesn't work unless I put the sidebar div
before the content div in the html and I don't want to do that.

What is wrong with correctly ordering the elements to achieve your
target design?

Well, nothing, that is, if all I'm trying to achieve is a visually
appealing page. It's, however, my understanding that the point of
designing with XHTML and CSS is so that you can layout the HTML
semantically and then apply a style sheet to make it look great.

Okay. Float both content and sidebar; content, float:left; sidebar:
float:right. Then it does not matter which comes first. And you can swap
positions by changing the float direction. Be sure to clear:both in the
footer.
Floating both divs works as long as both are a fixed width, or both are
a percentage width (totaling less than 100%). Otherwise one may wrap below
the other.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 2 '05 #10

P: n/a
"kchayka" <us****@c-net.us> wrote :
Shawn Wilson wrote:
What you're trying to accomplish is called a 'faux' layout


Who besides you calls it 'faux'? I have never heard of such a thing, and
I've been around here for a long time. Regardless, a JavaScript solution
is no solution, at least for many people. In most cases, JS isn't
necessary anyway.


Well, I didn't call it anything until a few weeks ago when I heard that term
and then did a google search for it and found out that the wold calls it
that. Maybe it's a crossover from print layout, I don't know, but it's
definately the term to search for this layout. Everything that's been
pointed out here is in one google search... 'faux columns with css'

A search for '3 column layout with css' gets 223,000 results, while 'faux
columns with css' only gets 10,100 - but the faux search only returns
results for exactly the layout problems and solutions that we're talking
about here. The '3 column layout with css' search finds many things that
match as well, but many that do not.

I just started using that term when I found that a search for it returned
exactly what I was looking for, that's all.

--
Shawn Wilson
Sep 2 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.