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 / April 2005



Tip: Looking for answers? Try searching our database.

absolute div in table cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 28 Apr 2005 14:16 GMT
Hi,

I am trying to add a background to a cell that contains multiple
horizontal coloured layers on top of eachother.

I managed to do this in IE, but firefox displays something very
different so I would like to know if my HTML is in error or firefox.

This is my HTML

http://www.xs4all.nl/~rvanloen/example/table.html

There are two problem in firefox. The first is that the coloured divs
are not visible. The second is that the absolute div is taking 100%
width and height of the complete window, instead of the containing
block. I have set the cell to position relative so that the div would be
the containg clock.
http://www.w3.org/TR/CSS21/visuren.html#propdef-position
http://www.w3.org/TR/CSS21/visudet.html#containing-block-details

Hope that someone can tell me that my HTML/CSS is wrong and tell me why.
Els - 28 Apr 2005 14:42 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> There are two problem in firefox. The first is that the coloured divs
> are not visible.

That's because you  have z-index:-1. Take the z-index off, and you'll
see the colours.

> The second is that the absolute div is taking 100%
> width and height of the complete window, instead of the containing
> block.

That's because you gave it position:absolute, which takes it out of
the normal flow.

> I have set the cell to position relative so that the div would be
> the containg clock.

No, it isn't the containing block, it's only the block to which it's
relatively positioned.

Why don't you just give the td a background image like so:

http://locusmeus.com/test/robert.html

Signature

Els                     http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
                            - Renato Russo -

Robert - 28 Apr 2005 15:04 GMT
Hi Els,

>>I am trying to add a background to a cell that contains multiple
>>horizontal coloured layers on top of eachother.
[quoted text clipped - 4 lines]
> That's because you  have z-index:-1. Take the z-index off, and you'll
> see the colours.

Okay, but then I won't be able to see the text :)
I want to push the div's behind the text.

>>The second is that the absolute div is taking 100%
>>width and height of the complete window, instead of the containing
>>block.
>
> That's because you gave it position:absolute, which takes it out of
> the normal flow.

Yes, I wanted to take it out of the normal flow so I could overlay the
text on it.

>>I have set the cell to position relative so that the div would be
>>the containg clock.
>
> No, it isn't the containing block, it's only the block to which it's
> relatively positioned.

But the W3C spec says that:
The containing block of an element is defined as follows:
(4)If the element has 'position: absolute', the containing block is
established by the nearest ancestor with a 'position' of 'absolute',
'relative' or 'fixed', in the following way:
(4-2)not inline -> the containing block is formed by the padding edge of
the ancestor.

So the TD should be the containing block.
Right?

> Why don't you just give the td a background image like so:
>
> http://locusmeus.com/test/robert.html

Because the table is dynamically created and each cell may contain more
than 2 colours where each has a different percentage. We are actually
determining how far we can go in converting a Java swing application
into a HTML web application.
Els - 28 Apr 2005 15:45 GMT
On Thu, 28 Apr 2005 16:04:49 +0200, in
comp.infosystems.www.authoring.stylesheets you wrote:

>>>I am trying to add a background to a cell that contains multiple
>>>horizontal coloured layers on top of eachother.
[quoted text clipped - 7 lines]
> Okay, but then I won't be able to see the text :)
> I want to push the div's behind the text.

I guess you'll have to add z-index +1 to the text then, and give the
div's z-index 0.

>>>The second is that the absolute div is taking 100%
>>>width and height of the complete window, instead of the containing
[quoted text clipped - 22 lines]
> So the TD should be the containing block.
> Right?

Not sure - it may be called a containing block, but obviously, the
divs don't stay inside of it. Haven't done an in-depth study of it :-)

>> Why don't you just give the td a background image like so:
>>
[quoted text clipped - 4 lines]
> determining how far we can go in converting a Java swing application
> into a HTML web application.

Okay, in that case it's more complicated.
Not impossible though - I've updated the same file:
http://locusmeus.com/test/robert.html

The only drawback I can see so far is the positioning of the '333'
height wise. If the height of the cell would always be 50px, then
line-height:50px gives the number the right height. But when enlarging
the font, it doesn't stay on the same level compared to the rest of
the numbers in the cells.

Signature

Els                     http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
                            - Renato Russo -

Robert - 28 Apr 2005 16:18 GMT
>>But the W3C spec says that:
>>The containing block of an element is defined as follows:
[quoted text clipped - 9 lines]
> Not sure - it may be called a containing block, but obviously, the
> divs don't stay inside of it. Haven't done an in-depth study of it :-)

They do stay inside with IE. Could it possibly be that Microsoft did
something right this time? :p

> Okay, in that case it's more complicated.
> Not impossible though - I've updated the same file:
> http://locusmeus.com/test/robert.html

Ok interesting. You made the text absolute instead of the colours, so
that the text will be in front. And set the line-height so the span
would not go outside the cell. I don't see the problem when I make the
font bigger.

I don't like that I have to set the height in so many places, but it
does give some possibilities.

Thanks.
 
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.