Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / December 2003



Tip: Looking for answers? Try searching our database.

Mixing relative and absolute... go boom...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Quiet Desperation - 27 Dec 2003 17:25 GMT
I started with this:

#section
{
  position: relative;
  width: 100%;
}

and

<div id="section">
  Section 1
</div>
<div id="section">
  Section 2
</div>
<div id="section">
  Section 3
</div>

This worked as expected. I got:

Section 1
Section 2
Section 3

To the CSS I added:

#column21
{
  position: absolute;
  width: 20%;
}

#column22
{
  position: absolute;
  margin-left: 20%;
  width: 30%;
}

#column23
{
  position: absolute;
  margin-left: 50%;
  width: 50%;
}

And changed the HTML to

<div id="section">
  Section 1
</div>
<div id="section">
  <div id="column21">
     Column21
  </div>
  <div id="column22">
     Column22
  </div>
  <div id="column23">
     Column23
  </div>
</div>
<div id="section">
  Section 3
</div>

The columns themselves worked great, but "Section 3" is now written
*over* the new 3-column section 2, right after Section 1.

I expected:
Section 1
Column21       Column22            Column23
Section3

I got:
Section 1
#########      Column22            Column23

where "#########" is "Column21" and "Section 3" written on top on one
another.

It appears that Section 1 renders normally, the new section 2 is placed
properly relative, the absolute columns are placed properly, but when
it comes time to place section 3, the new section to is somehow negated
from the flow, and section 3 is place right after section 1 as if the
new section 2 were never there.

This result is really counterintuitive to me. It does the same thing in
IE5 and Safari on Mac OS X and IE6 on WinXP, so I have to believe I'm
missing something in the CSS spec. Either that or I can chalk it up as
another expected result of standards designed by a committee. ;-)
David Dorward - 27 Dec 2003 17:35 GMT
> I started with this:

> <div id="section">
>    Section 1
[quoted text clipped - 9 lines]
> </div>
> <div id="section">

You have syntax errors. You can't have five "The one and only element in
this document called 'section'".

http://css-discuss.incutio.com/?page=ClassesVsIds
http://validator.w3.org/

> another expected result of standards designed by a committee.

I skimmed the rest of the message _very_ quickly, bit this caught my eye.

Don't blame the standard until you conform to it.

Signature

David Dorward                                      <http://dorward.me.uk/>

Quiet Desperation - 27 Dec 2003 19:26 GMT
> You have syntax errors. You can't have five "The one and only element in
> this document called 'section'".

I had three. Something might be getting narfed somewhere between my
newsreader and yours.

Actually, I did initially try three separate CSS id definitions
(section1, section2, section3) and got the same result. I posted this
one because it was shorter. In all my fiddling this morning I forgot
ids were one shots.

> I skimmed the rest of the message _very_ quickly, bit this caught my eye.

Oh c'mon. I put a smiley. I'm a big CSS booster, but I do feel some of
the web standards are a bit more obtuse than they really need to be.

Thanks for the link.
kchayka - 28 Dec 2003 12:53 GMT
> I started with this:

Code snippets rarely tell the whole story.  Please post a URL.

Signature

To email a reply, remove (dash)un(dash).  Mail sent to the un
address is considered spam and automatically deleted.

Quiet Desperation - 28 Dec 2003 16:18 GMT
> Code snippets rarely tell the whole story.  Please post a URL.

It's not online anywhere. It was just an experiment.
Michael Rozdoba - 28 Dec 2003 13:45 GMT
[snip code fragments]

> The columns themselves worked great, but "Section 3" is now written
> *over* the new 3-column section 2, right after Section 1.

Yup.

> I expected:
> Section 1
> Column21       Column22            Column23
> Section3

Why did you expect this?

> I got:
> Section 1
[quoted text clipped - 8 lines]
> from the flow, and section 3 is place right after section 1 as if the
> new section 2 were never there.

Exactly.

> This result is really counterintuitive to me.

Why are you specifying position values other than static, but then not
actually bothering to specify any positions?

What are you trying to achieve?

> It does the same thing in IE5 and Safari on Mac OS X and IE6 on
> WinXP, so I have to believe I'm missing something in the CSS spec.
> Either that or I can chalk it up as another expected result of
> standards designed by a committee. ;-)

The former ;)

Try reading http://www.w3.org/TR/CSS2/visuren.html#positioning-scheme

Specifically the part which says "Absolutely positioned boxes are taken
out of the normal flow".

HTH.

Signature

Michael
m r o z a t u k g a t e w a y d o t n e t

Quiet Desperation - 28 Dec 2003 16:17 GMT
> Specifically the part which says "Absolutely positioned boxes are taken
> out of the normal flow".

I knew that, but I find it counterintuitive that absolute DIVs *inside*
a *relative* DIV remove the containing relative DIV from the flow. It
feels like the absoluteness of the child DIVs are cascading back upward
to the parent. The containing relative DIV should act like a little
pocket universe. To the top flow it's just another relative DIV. It
would be a lot better, IMHO, if it worked this way. There's several
CSS-P issues I have run into that would be easily solved by this
behavior.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.