469,602 Members | 1,823 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

z-index problem

hello there,
i'm having a problem with the z-index.
when i set the value it's not moving the object into the background as i
want it.

the site is something like this (this here is simplified)

<body>
<div class="one">
<img src="./1.gif" />
</div>

<div class="two">
<table class="content">
.....
</table>
</div>
</body>
while the css is like this:

body {
background-image: url(./bg.gif);
}

..one {
position: absolute;
left:0px;
top:214px;
z-index:1;
}

..two {
z-index:100;
}

..content {
background-color:#fff;
}
I'm having only trouble with this one image that's always in front, but
i want it to be behind the table, that's why i added another div around
the table, but it didn't help either.
Does it have todo with the position:absolute? Or is it breaking appart,
as i have more elements in the table?

The reason why i want todo it like this is, that the background image is
a pattern, but this one image should only be once in there, not multiple
times.

Anyone an idea where i'm doing something wrong here?
Jul 21 '05 #1
11 6340
*Oliver* <ol**********@web.de>:

<body>
<div class="one"><img src="./1.gif" /></div>
Why the 'div'?
<div class="two"><table class="content">.....</table></div>
Why the 'div'?
</body>

body {background-image: url(./bg.gif);}
.one {
position: absolute;
top:214px;
z-index:1;
}
.two {z-index:100;}
".two" is not positioned ('static'), thus 'z-index' does not apply.
.content {background-color:#fff;}

The reason why i want todo it like this is, that the background image is
a pattern, but this one image should only be once in there, not multiple
times.


Why don't you put it into 'background' of the 'table' then? Set
'background-position' and 'background-repeat' accordingly. That would
result in something like

<body><table class="content">.....</table></body>

body {background-image: url(./bg.gif)}
.content {background: white url(./1.gif) 0 214px no-repeat}

--
"It is better to know some of the questions than all of the answers."
James Thurber
Jul 21 '05 #2
Christoph Paeper <ch**************@nurfuerspam.de> wrote:
*Oliver* <ol**********@web.de>:

<body>
<div class="one"><img src="./1.gif" /></div>
Why the 'div'?


If he's using Strict, the IMG *has* to be in a block. You can't have
inline elements directly inside the body.
<div class="two"><table class="content">.....</table></div>


Why the 'div'?


Right, not necessary for validity.
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 21 '05 #3
Christoph Paeper schrieb:
*Oliver* <ol**********@web.de>:

<body>
<div class="one"><img src="./1.gif" /></div>

Why the 'div'?


As said by other member, i'm using strict
<div class="two"><table class="content">.....</table></div>

Why the 'div'?


Just for testing purposes. I said i tried it first without it and
thought maybe it helps
</body>

body {background-image: url(./bg.gif);}
.one {
position: absolute;
top:214px;
z-index:1;
}
.two {z-index:100;}

".two" is not positioned ('static'), thus 'z-index' does not apply.


position:static; didn't help, change anything
.content {background-color:#fff;}

The reason why i want todo it like this is, that the background image
is a pattern, but this one image should only be once in there, not
multiple times.

Why don't you put it into 'background' of the 'table' then? Set
'background-position' and 'background-repeat' accordingly. That would
result in something like

<body><table class="content">.....</table></body>

body {background-image: url(./bg.gif)}
.content {background: white url(./1.gif) 0 214px no-repeat}


Because the table is samller than where the image should appear.
The image should always be on the very left of the screen, while the
table is centered to the screen. Thus i can't put that image into the
background of the table.
Thanks anyhow, u have another idea?
Jul 21 '05 #4
Oliver wrote:
Because the table is samller than where the image should appear.
The image should always be on the very left of the screen, while the
table is centered to the screen. Thus i can't put that image into the
background of the table.
Thanks anyhow, u have another idea?


You have a positioned image partially obscurred by an overlapping table
and the image is greater than the table itself. The position of the
image and that of the table are required to remain as is. The image is
required to extend into the table as a background image of the table.

The solution here is to keep the image which is partially hidden by the
table, use the same image as a background image in the table and
position this background image such that it seems that it is one image
extending into the table are. The idea is that if the background image
is moved outside of (beyond) the table border, that portion will not be
visible. Since the background image applied to the table is
background-attachment:scroll by default, the reference is to the top and
left edges of the table. So by applying negative values to
background-position for the background image of the table until it abuts
seamlessly with the other identical image will result in what seems to
be one complete image.
i.e. background: white url(./1.gif) no-repeat -??px -/+??px;

If the requirement is to have the image portion outside of table to also
be a background image, then place the table inside a div and apply the
image also as a background image to the div using the same declaration
as for the table but with different positive background-position values.
It may also be necessary to position the div itself depending on the
need. In anticipation of further difficulties, it may also be necessary
to place the table within another immediate div in order to position the
table.

The concept is simple - the solution and explanation longer than I
expected or I went into too much detail and hopefully did not confuse.

--
Gus
Jul 21 '05 #5
*Oliver* <ol**********@web.de>:
Christoph Paeper schrieb:
".two" is not positioned ('static'), thus 'z-index' does not apply.


position:static; didn't help, change anything


Of course not, that is what it is already by default. I should have been
more verbose, probably.
The reason why i want todo it like this is, that the background
image is a pattern, but this one image should only be once in there,


Why don't you put it into 'background' of the 'table' then?


Because the table is samller than where the image should appear.


Well, 'background-position' accepts negative values, too, or maybe
"background-attachment: fixed" suits your need, elsewise you probably do
need that containing 'div' (in theory you could assign the images to
'html' and 'body' instead).

--
"Right way turning, Listen we are learning.
Head's full of noise, Chicken's got no choice.
Heads are rollin', Chicken blood is stolen.
The rest of the chicken wants a picke-nicken" Guano Apes - We use the Pain
Jul 21 '05 #6
Oliver wrote:
.two {z-index:100;}

".two" is not positioned ('static'), thus 'z-index' does not apply.


position:static; didn't help, change anything


I think he may have meant to say "position: relative;" or "position:
absolute;".

--
niall

Jul 21 '05 #7
Oliver wrote:
.two {z-index:100;}

".two" is not positioned ('static'), thus 'z-index' does not apply.


position:static; didn't help, change anything


I think he may have meant to say "position: relative;" or "position:
absolute;".

--
niall

Jul 21 '05 #8
Oliver wrote:
<snip>

position:static; didn't help, change anything


Evidently, since it's the default positioning! Try
position: relative
Jul 21 '05 #9
Gus Richter schrieb:
Oliver wrote:
Because the table is samller than where the image should appear.
The image should always be on the very left of the screen, while the
table is centered to the screen. Thus i can't put that image into the
background of the table.
Thanks anyhow, u have another idea?

You have a positioned image partially obscurred by an overlapping table
and the image is greater than the table itself. The position of the
image and that of the table are required to remain as is. The image is
required to extend into the table as a background image of the table.

The solution here is to keep the image which is partially hidden by the
table, use the same image as a background image in the table and
position this background image such that it seems that it is one image
extending into the table are. The idea is that if the background image
is moved outside of (beyond) the table border, that portion will not be
visible. Since the background image applied to the table is
background-attachment:scroll by default, the reference is to the top and
left edges of the table. So by applying negative values to
background-position for the background image of the table until it abuts
seamlessly with the other identical image will result in what seems to
be one complete image.
i.e. background: white url(./1.gif) no-repeat -??px -/+??px;

If the requirement is to have the image portion outside of table to also
be a background image, then place the table inside a div and apply the
image also as a background image to the div using the same declaration
as for the table but with different positive background-position values.
It may also be necessary to position the div itself depending on the
need. In anticipation of further difficulties, it may also be necessary
to place the table within another immediate div in order to position the
table.

The concept is simple - the solution and explanation longer than I
expected or I went into too much detail and hopefully did not confuse.

hey,
ok i did manage to get it right. i used a surroundig div tag for the
table and added a background with the gif and used background-position.
Thanks for your help
Jul 21 '05 #10
Oliver wrote:
Gus Richter schrieb:
Oliver wrote:
Because the table is samller than where the image should appear.
The image should always be on the very left of the screen, while the
table is centered to the screen. Thus i can't put that image into the
background of the table.
Thanks anyhow, u have another idea?


You have a positioned image partially obscurred by an overlapping
table and the image is greater than the table itself. The position of
the image and that of the table are required to remain as is. The
image is required to extend into the table as a background image of
the table.

The solution here is to keep the image which is partially hidden by
the table, use the same image as a background image in the table and
position this background image such that it seems that it is one image
extending into the table are. The idea is that if the background image
is moved outside of (beyond) the table border, that portion will not
be visible. Since the background image applied to the table is
background-attachment:scroll by default, the reference is to the top
and left edges of the table. So by applying negative values to
background-position for the background image of the table until it
abuts seamlessly with the other identical image will result in what
seems to be one complete image.
i.e. background: white url(./1.gif) no-repeat -??px -/+??px;

If the requirement is to have the image portion outside of table to
also be a background image, then place the table inside a div and
apply the image also as a background image to the div using the same
declaration as for the table but with different positive
background-position values. It may also be necessary to position the
div itself depending on the need. In anticipation of further
difficulties, it may also be necessary to place the table within
another immediate div in order to position the table.

The concept is simple - the solution and explanation longer than I
expected or I went into too much detail and hopefully did not confuse.

hey,
ok i did manage to get it right. i used a surroundig div tag for the
table and added a background with the gif and used background-position.
Thanks for your help


I'm glad you were able to make sense out of my ramblings. ;-)

--
Gus
Jul 21 '05 #11
Gus Richter schrieb:
Oliver wrote:
Gus Richter schrieb:
Oliver wrote:

Because the table is samller than where the image should appear.
The image should always be on the very left of the screen, while the
table is centered to the screen. Thus i can't put that image into
the background of the table.
Thanks anyhow, u have another idea?


You have a positioned image partially obscurred by an overlapping
table and the image is greater than the table itself. The position of
the image and that of the table are required to remain as is. The
image is required to extend into the table as a background image of
the table.

The solution here is to keep the image which is partially hidden by
the table, use the same image as a background image in the table and
position this background image such that it seems that it is one
image extending into the table are. The idea is that if the
background image is moved outside of (beyond) the table border, that
portion will not be visible. Since the background image applied to
the table is background-attachment:scroll by default, the reference
is to the top and left edges of the table. So by applying negative
values to background-position for the background image of the table
until it abuts seamlessly with the other identical image will result
in what seems to be one complete image.
i.e. background: white url(./1.gif) no-repeat -??px -/+??px;

If the requirement is to have the image portion outside of table to
also be a background image, then place the table inside a div and
apply the image also as a background image to the div using the same
declaration as for the table but with different positive
background-position values. It may also be necessary to position the
div itself depending on the need. In anticipation of further
difficulties, it may also be necessary to place the table within
another immediate div in order to position the table.

The concept is simple - the solution and explanation longer than I
expected or I went into too much detail and hopefully did not confuse.

hey,
ok i did manage to get it right. i used a surroundig div tag for the
table and added a background with the gif and used background-position.
Thanks for your help

I'm glad you were able to make sense out of my ramblings. ;-)

Was kinda hard, but after reading it 10 times it made sense. ;)
Jul 21 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Greg | last post: by
22 posts views Thread by DJ WIce | last post: by
8 posts views Thread by rdlebreton | last post: by
6 posts views Thread by Kekec | last post: by
2 posts views Thread by sorobor | last post: by
7 posts views Thread by raknin | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.