I would like to do something that seems so basic with two div's but I
don't think it can be done. Tables can do it in a snap. I was
convinced that css was the way to go for layout but without being able
to do even the easiest things, I don't see how.
Here is the table way to do the layout (I want this to work in
compliance mode in all modern browsers.):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-loose.dtd">
<html>
<head>
<style type="text/css">
body{margin:0px;height:100%;}
</style>
</head>
<body>
<table style="height:100%;" cellpadding="0" cellspacing="0">
<tr>
<td style="background-color:blue">
Some Text
</td>
<td style="background-color:red;width:100%;text-align:center">
<div style="width:400px">
A Lot More Text A Lot More Text
</div>
</td>
</tr>
</table>
</body>
</html>
I want to have the left column shrink to fit the text and the right
column to be a 100% of the left over viewport. Sounds simple.
Here's what won't work in IE. You'll notice that as soon as you touch
the 400px div with the viewport the whole thing drops to the bottom.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-loose.dtd">
<html>
<head>
<style type="text/css">
body{margin:0px;height:100%;}
#nav{float:left;height:100%;background-color:blue;}
#content{height:100%;background-color:red;text-align:center;}
</style>
</head>
<body>
<div id="nav">
Some Text
</div>
<div id="content">
<div style="width:400px">
A Lot More Text A Lot More Text
</div>
</div>
</body>
</html>
Tyler
Tyler Carver wrote:
> I want to have the left column shrink to fit the text and the right
> column to be a 100% of the left over viewport. Sounds simple.
>
> Here's what won't work in IE. You'll notice that as soon as you touch
> the 400px div with the viewport the whole thing drops to the bottom.
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en"
> "http://www.w3.org/tr/xhtml1/dtd/xhtml1-loose.dtd">
> <html>
> <head>
> <style type="text/css">
> body{margin:0px;height:100%;}
> #nav{float:left;height:100%;background-color:blue;}
> #content{height:100%;background-color:red;text-align:center;}
> </style>
> </head>
> <body>
> <div id="nav">
> Some Text
> </div>
> <div id="content">
> <div style="width:400px">
> A Lot More Text A Lot More Text
> </div>
> </div>
> </body>
> </html>
>
Yes this is called a liquid layout, which you have created by using
relative positioning, which is the default for css. If you don't want
anything to move, use absolute positioning. Here is one way to do it:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<style type="text/css">
body{margin:0px;height:100%;}
#nav{position:absolute; background-color:blue; width:100px;
height:100%;}
#content{position:absolute; left:100px; width:100%; height:100%;
background-color:red; text-align:center; }
</style>
</head>
<body>
<div id="nav">
Some Text
</div>
<div id="content">
A Lot More Text A Lot More Text
</div>
</body>
</html>
Tyler Carver wrote:
> I want to have the left column shrink to fit the text and the right
> column to be a 100% of the left over viewport. Sounds simple.
>
> Here's what won't work in IE. You'll notice that as soon as you touch
> the 400px div with the viewport the whole thing drops to the bottom.
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en"
> "http://www.w3.org/tr/xhtml1/dtd/xhtml1-loose.dtd">
> <html>
> <head>
> <style type="text/css">
> body{margin:0px;height:100%;}
> #nav{float:left;height:100%;background-color:blue;}
> #content{height:100%;background-color:red;text-align:center;}
> </style>
> </head>
> <body>
> <div id="nav">
> Some Text
> </div>
> <div id="content">
> <div style="width:400px">
> A Lot More Text A Lot More Text
> </div>
> </div>
> </body>
> </html>
>
>
This is called a liquid layout, which you have created by using relative
positioning, which is the default for css. If you don't want anything to
move, use absolute positioning. Here is one way to do it:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<style type="text/css">
body{margin:0px;height:100%;}
#nav{position:absolute; background-color:blue; width:100px;
height:100%;}
#content{position:absolute; left:100px; width:100%; height:100%;
background-color:red; text-align:center; }
</style>
</head>
<body>
<div id="nav">
Some Text
</div>
<div id="content">
A Lot More Text A Lot More Text
</div>
</body>
</html>
On 21 Jul 2004 14:24:02 -0700, xfreshy222-2@yahoo.com (Tyler Carver)
wrote:
>I would like to do something that seems so basic with two div's but I
>don't think it can be done...
Sure you can; there's a lot of interesting ideas that can be realized
already with CSS1 properties only.
<http://www.css.nu/articles/table-in-css.html>
You should of course forget the use of a "Transitional" <DOCTYPE...
declaration and make sure that your browser operates in its best
possible rendering mode.
--
Rex
On Wed, 21 Jul 2004, Red wrote:
> This is called a liquid layout, which you have created by using relative
> positioning, which is the default for css.
splendid.
> If you don't want anything to move, use absolute positioning.
If you don't want anything to move - think again. It's going to move
anyway, for some readers, so you might do better to work -with- the
properties of the medium. Some CSS properties are more suitable for
specific display situations, but are better avoided when the result
will be displayed over the whole range of display situations on the
WWW.
Unless you're a real wizard with graceful fallback techniques, but
then surely you'd know better than to ask for "nothing to move".
cheers
Red <groups@reenie.org> wrote:
>This is called a liquid layout, which you have created by using relative
>positioning, which is the default for css.
Static is the default.
>If you don't want anything to
>move, use absolute positioning.
Many beginners make the mistake of thinking that css absolute
positioning is the way to create pixel prefect layouts that will look
the same in every css browser. Most of the time what they produce not
only does not achieve the desired goal, it fights the strengths of the
medium. There are relatively few cases where using css absolute
positioning makes sense, and in the cases where it does it requires
considerable skill to understand, implement and to reduce the associated
drawbacks (some are unavoidable).
Bottom line: stay away from absolute positioning until you are a skilled
css'er.
--
Spartanicus
Spartanicus wrote:
> Red <groups@reenie.org> wrote:
>
>
>
>
> Static is the default.
>
>
>
>
> Many beginners make the mistake of thinking that css absolute
> positioning is the way to create pixel prefect layouts that will look
> the same in every css browser. Most of the time what they produce not
> only does not achieve the desired goal, it fights the strengths of the
> medium. There are relatively few cases where using css absolute
> positioning makes sense, and in the cases where it does it requires
> considerable skill to understand, implement and to reduce the associated
> drawbacks (some are unavoidable).
>
> Bottom line: stay away from absolute positioning until you are a skilled
> css'er.
>
Are you really saying don't use absolute postitioning at all ? Most
layout tutorials such as http://bluerobot.com/web/layouts/layout1.html
use it to some extent.
What in particular are the drawbacks of the particular code I posted ?
I'll post it again below, and here is an url:
http://www.reenie.org/test/csstest.htm
It seemed to do what the original poster wanted. How would you make this
layout without using absolute positioning ?
The only reason I made the content column absolute is that height:100%
doesn't work with relative positioning, and it seemed like the original
poster wanted the columns to fill the screen. The original poster also
complained that the right hand column moved to the bottom when the
screen is narrow- and I agree it can be ugly when that happens.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<style type="text/css">
body{margin:0px;height:100%;}
#nav{position:absolute; background-color:blue; width:100px;
height:100%;}
#content{position:absolute; left:100px; width:100%; height:100%;
background-color:red; text-align:center; }
</style>
</head>
<body>
<div id="nav">
Some Text
</div>
<div id="content">
A Lot More Text A Lot More Text
</div>
</body>
</html>
Spartanicus wrote:
> Red <groups@reenie.org> wrote:
>
>
>
>
> Static is the default.
>
relative positioning is static ? How is that ? Doesn't make any sense to
me. I seems that absolute positioning would be considered static, and
it surely is not the default.
>
>
>
> Many beginners make the mistake of thinking that css absolute
> positioning is the way to create pixel prefect layouts that will look
> the same in every css browser. Most of the time what they produce not
> only does not achieve the desired goal, it fights the strengths of the
> medium. There are relatively few cases where using css absolute
> positioning makes sense, and in the cases where it does it requires
> considerable skill to understand, implement and to reduce the associated
> drawbacks (some are unavoidable).
>
> Bottom line: stay away from absolute positioning until you are a skilled
> css'er.
>
Are you really saying don't use absolute postitioning at all ? Most
layout tutorials such as http://bluerobot.com/web/layouts/layout1.html
use it to some extent.
What in particular are the drawbacks of the particular code I posted ?
I'll post it again below, and here is an url:
http://www.reenie.org/test/csstest.htm
It seemed to do what the original poster wanted.
The only reason I made the content column absolute is that height:100%
doesn't work with relative positioning, and it seemed like the original
poster wanted the columns to fill the screen. The original poster also
complained that the right hand column moved to the bottom when the
screen is narrow- and I agree it can be ugly when that happens.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test</title>
<style type="text/css">
body{margin:0px;height:100%;}
#nav{position:absolute; background-color:blue; width:100px;
height:100%;}
#content{position:absolute; left:100px; width:100%; height:100%;
background-color:red; text-align:center; }
</style>
</head>
<body>
<div id="nav">
Some Text
</div>
<div id="content">
A Lot More Text A Lot More Text
</div>
</body>
</html>
Red wrote:
> Spartanicus wrote:
>
>
> relative positioning is static ? How is that ? Doesn't make any sense to
> me. I seems that absolute positioning would be considered static, and
> it surely is not the default.
Read in the CSS spec about positioning. Values are 'static', 'relative',
'absolute', or 'fixed'. The default is 'static'.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Johannes Koch wrote:
>
> Read in the CSS spec about positioning. Values are 'static', 'relative',
> 'absolute', or 'fixed'. The default is 'static'.
OK sorry. I thought had I read it some book, but I guess I was mistaken.
red