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

absolute div in table cell

P: n/a
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.h...opdef-position
http://www.w3.org/TR/CSS21/visudet.h...-block-details

Hope that someone can tell me that my HTML/CSS is wrong and tell me why.
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Els
Robert wrote:
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.
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
--
Els http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 21 '05 #2

P: n/a
Hi Els,

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

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.


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.
Jul 21 '05 #3

P: n/a
Els
On Thu, 28 Apr 2005 16:04:49 +0200, in
comp.infosystems.www.authoring.stylesheets you wrote:
Els wrote:
I am trying to add a background to a cell that contains multiple
horizontal coloured layers on top of eachother.

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.


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
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?


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:

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.


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.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -
Jul 21 '05 #4

P: n/a
>>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?

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.
Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.