Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table td cells layers overlap absolute content?

Status
Not open for further replies.

cmndline

Programmer
Apr 21, 2008
3
0
0
US
I investigated ways of displaying larger sized images on a web page. Thus developed code that has small thumbnail images positioned on the left and right sides of a two td table cell column page that when mouseOver'd switch to a larger image to display in the page. The reason for doing this is to limit the bandwidth required to load several full sized larger images into pages, to reduce image space of those larger images so as to not clutter up pages where text needs to be maximized, and given the greater space then available, include more available images into a page. The first method I used to implement this was with popup windows. However functional that had been, the blocking of that function by most users limits its practical usefulness. Note I am using IE-6.


I then coded this later code that has one serious problem of right td cell objects interfering with left td cell objects. The functional implication is that larger images have other objects interfering visually in layers above them. To debug such I simplified the code removing external css references, images, leaving just the span boxes, so as to make the debug code standalone. I ran this through the w3c validators. This is a link to the standalone debug file to view the problem and look at the source code:


The table structure of the page is a single row of two adjacent 50% width td cells.

Inside each td row cell is a bit of expalnatory text inside a paragraph and a small relatively positioned span box that has a child absolutely positioned span box slightly smaller inside. It is the child span boxes, boxa-click and boxb-click, that form half of javascript mouseOver and mouseClick switching statements. By mousing over either of these internal boxes, a different class becomes active in the span that switches to larger absolutely positioned boxes, boxa_mover and boxb_mover. Note that also leaves the background container span boxes at the page sides. I have positioned the larger boxes so they will overlap elements in the adjacent table cells if one narrows their browser window width a bit.

The basic problem that occurs that I have not been able to resolve is, regardless of what I do, whenever the larger box from the left td cell displays after a mouseover, the adjacent cell right boxes are not transparent so appear on top as though they had a higher layer value. Interestingly the text in the right td cell is correctly below the larger box. Conversely whenever the larger box from the right td cell displays after a mouseover, the adjacent cell boxes are correctly transparent so it appears below as though they had a lower layer value. Thus the problem is td cell position dependent only on one side.

Any settings of z-index in either td cells have no bearing on what occurs when absolute boxes overlap the span elements in the adjacent td row cells. That may be at the root of the problem due to peculiarities of the IE browser implemention. If I simplify the code so there is only a single absolute span element in each cell, the same issue occurs. However setting it up as I have done allows a better visual debug indication of what is occurring. Likewise removing the float terms has no effect.

If I change the position selector for boxa-mover or boxb-mover from absolute to relative, when a mouseOver is actuated, boxa-mover or boxb-mover, causes the columns to expand in width from 50%/50% to say 80%/20% instead of overlapping into the adjacent td row areas. Thus that tells nothing about the problem in absolute mode.

So it appears the problem is that positioned absolute boxes from the left td cell if overlapping absolutely postioned boxes in the right td cell, will display below their layer thus blocking full visibility.

I'm wondering if I'm missing something obvious and there is a simple solution to this or if I ought to just give up and consider it just another browser implementation limitation? ...David
 
I can't see immediately what's causing your problem. As you say, IE can be pretty cranky with the way it does things.

My suggestion would be not to re-invent the wheel and use some of the great stuff already out there. For example, how about "lightbox":
I've got it working at and I'm pretty pleased with it.

Incidentally, I'd recommend that you only activate the bigger picture when the user clicks on the thumbnail, rather than mouseover. It can be really irritating if stuff happens accidentally as you're moving the mouse somewhere (e.g. when you mouse over an inline ad in Tek Tips!)

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks for the link Chris. I'd already taken a brief look at that. Not that appealing to where I want to go with this because functionally from the user perspective, operations are nearly identical to code using window.open popups. Replacing the whole window frame with content instead is of course simpler to implement and I could likely code something like that with less effort if I wished to. Snagging the window size is a lot easier than dealing with where the scroll bar positions happen to be.

But then it seems I may be looking at a dead end without recourse than to implement this differently. Likely will explore using a div block layout instead of table based layout since there are a lot of unexpected worms in browser table implementations.

The unfortunately confusingly complicated CSS2 spec is at the root of a lot of our browser implementation issues. The authors couldn't write that stuff understandable enough even for other experts to implement correctly. Thus the usual shortsighted software standards engineering due to not bothering to have specs reviewed by uninterested third party users. They are always most interested in fighting amongst themselves over spec issues than making such understandable to the peons that will later use such.
 
Try modifying the Z-index of your different objects to get them under each other the way you want to.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
cmndline, your issue is simple and it will never be solved.

The table plays no role. It is a non-positioned item, so it has no say in the z-index battle. From here on out it's just the two relatively positioned elements and the absolutely positioned elements.

Now you need to understand that z-index works only between the sibling elements. You have two sibling elements. Those are the two relative positioned spans. They are sibling because they're both the first positioned items (they have no positioned parent anywhere above them). They both have one child, the absolutely positioned span. Since that is their only child, specifying the z-index in that one is futile, because it will always hover above the parent element (the relatively positioned span) and there are no other sibling elements in the same container.

So, the only thing you can play with is the z-index of the relatively positioned spans. First rule is, the item that appears later in the code will have higher z-index. That means that the right span (and all its child elements) will be above the left one (and all its child elements) unless specified otherwise. However, if you give the left one a higher z-index than the right one, then the left one (and all its child elements) will be above the right one (and all its child elements). And what you want is to have the child elements higher than both left and right relatively positoned spans. That cannot be done like that.

When you think of z-index, you need to think of boxes. If in one box, you want something to be at the very top of the box, you give it a high z-index. However, if you then take another box and put the whole other box on top of the first box, that item in the first box will still be covered by the second box. Because z-index is relative to the positioned parent.

Actually, if you're dealing with JavaScript, you might be able to solve this issue. When you hover over the relatively positioned span and change the class of that element, also change its z-index to be higher than the other one. Say if you do not specify any z-indexes on the relatively positioned spans, right will be above the left. However, if when hovering on the left you would give it a z-index of 10, then left would be above the right. And so on. This is how you could solve this issue.

The only other way would be to take the absolutely positioned elements outside their relatively positioned parents.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
cmndline said:
I'd already taken a brief look at [Lightbox]. Not that appealing to where I want to go with this because functionally from the user perspective, operations are nearly identical to code using window.open popups.
You might need to take a slightly longer look. Sure, Lightbox will pop images up in a new window if Javascript is disabled. With JS switched on you get a really slick presentation of the image - in the same browser window.

If Lightbox really doesn't suit you, I'd still suggest searching around for existing code that you can use rather than starting from scratch. Displaying images from thumbnails is not exactly a novel problem, why re-invent the wheel?

Vragabond said:
The table plays no role. It is a non-positioned item
If that's the issue here - and it may well be - then all cmndline would have to do to make it a positioned element would be to add [tt]position:relative[/tt] to its CSS. Would that help?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
I don't think it would make any difference. If table would be positioned, the two spans would still be siblings and their child elements would still suffer the same issues. I think the two ways I described (the second one is the same as used by lightbox variations) are the only ways of solving the issue.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Thanks vagabond for bringing the sibling child issue into more clarity. I read the box model and z-index section of the CSS2 spec over and over trying to make sense of it all and vaguely suspected what you more clearly understand. The spec is rather terse in its discussion of layers without a full range examples. I had tried about every permutation of z-index use in all rules while noting any effect. And there never was any.

In the mean time I gave up on that code and have implemented a change to my pages in a different way that is probably better anyway. I had been using mouseOvers to event trigger window.opens of larger images from thumbnails. I simply changed with global replacements in my files to onClick event triggers that then eliminates all the popup blocking issues. I still use mouseOut's to close those windows. To see how this actually looks, on my website homepage at:


At page top right select the sub-page link:

Spring 2008 Wildflower Chronicles

That brings up a Contents index page for that feature. Select any page below in the index, ie Page 1 thru Page 9, all of which have that functional implementation. Thus mouse left click a thumbnail imagemap to open a window and mouseout from the thumbnail imagemap to close such windows.

...David
 
mouseout from the thumbnail imagemap to close such windows
Wow, that's confusing! I wondered where my windows were going to! I must say, I much prefer the lightbox style approach.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top