472,952 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

Problem positioning layers

Hi,

I like a demo on layers posted at
http://www.echoecho.com/csslayers.htm. It displays two text phrases in
separate layers visually overlapped, first with one on top and the
other beneath, and then vise versa.

The site also provided the code they claimed produced this
(overlapping) effect. I plugged their code into the body of a vanilla
html shown below, but the items were not overlapped, neither with
Firefox nor IE.

What mistake am I making?

TIA,
Richard

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Title</title>
</head>
<body ondblclick="MyFunction(3)">
LAYER 1 ON TOP:
<div style="position:relative; font-size:50px; z-index:2;">LAYER
1</div>
<div style="position:relative; top:-50; left:5; color:red;
font-size:80px; z-index:1">LAYER 2</div>

LAYER 2 ON TOP:
<div style="position:relative; font-size:50px; z-index:3;">LAYER
1</div>
<div style="position:relative; top:-50; left:5; color:red;
font-size:80px; z-index:4">LAYER 2</div>
</body>
</html>

Apr 2 '06 #1
4 2004
Richard wrote :
Hi,

I like a demo on layers posted at
http://www.echoecho.com/csslayers.htm.
Tutorials and demo at echoecho.com are definitely *_not_* recommendable:
they are full of markup errors, validation errors, bad coding practices,
poor semantic markup, nested tables, no doctype decl. so documents
trigger backward-compatible rendering mode and not standards rendering
mode, etc.. My recommendation: Don't learn from that site.

It displays two text phrases in separate layers visually overlapped, first with one on top and the
other beneath, and then vise versa.

The site also provided the code they claimed produced this
(overlapping) effect. I plugged their code into the body of a vanilla
html shown below, but the items were not overlapped, neither with
Firefox nor IE.

What mistake am I making?

The first thing you should do when meeting problems or difficulties like
this is to validate the markup code with a validator.

W3C markup validator
http://validator.w3.org/

WDG HTML validator
http://www.htmlhelp.com/tools/validator/

Next, you do the same with the CSS code.

W3C CSS validator
http://jigsaw.w3.org/css-validator/

I repeat: there is no other first steps to do actually.
Next, you have to fix the errors so that you can rule out parsing errors
or fallback mechanisms in browsers when meeting invalid or improperly
nested elements.
TIA,
Richard

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Title</title>
</head>
<body ondblclick="MyFunction(3)">
LAYER 1 ON TOP:
<div style="position:relative; font-size:50px; z-index:2;">LAYER
1</div>
<div style="position:relative; top:-50; left:5; color:red;
font-size:80px; z-index:1">LAYER 2</div>
top is -50; the validator will report this as an error. No units are
specified for top and left. So this is a parsing error.

CSS1 and CSS 2.1 specifications require that non-zero values must be
specified with a length unit; otherwise, the css declaration will be
ignored. Mozilla-based browsers, MSIE 6+ (in standards compliant
rendering mode), Opera 7+, Safari 2.x and other W3C standards-compliant
browsers enforce such handling of parsing error.
CSS1 Forward-compatible parsing
http://www.w3.org/TR/REC-CSS1#forwar...atible-parsing
CSS2.1 Rules for handling parsing errors
http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

LAYER 2 ON TOP:
<div style="position:relative; font-size:50px; z-index:3;">LAYER
1</div>
<div style="position:relative; top:-50; left:5; color:red;
font-size:80px; z-index:4">LAYER 2</div>
Same problem here.
</body>
</html>


Finally, here, we have no idea what MyFunction(3) actually do. Post an
url and then we can figure this out.

You can try my own interactive positioning demo:

http://www.gtalbot.org/DHTMLSection/Positioning.html
(It won't perfectly work in MSIE 7 beta 2; I still need to fix a few
things). Also, the divs are either images or nested ones... which is not
the case of your html code).

Gérard
--
remove blah to email me
Apr 2 '06 #2
Hi Gérard,

Thank you VERY much for your analyis of the problem(s) and your
extensive guidance of how to code in this application area.
Tutorials and demo at echoecho.com are definitely *_not_* recommendable It's a sin that people so ill prepared have the temerity to offer advice to all the programmers on the planet. The first thing you should do when meeting problems or difficulties
like this is to validate the markup code with a validator.
Did that with all three validators -- in the process switched to HTML
from XHTML.
top is -50; the validator will report this as an error. No units are
specified for top and left. So this is a parsing error.
That didn't happen for some reason. But I'll change that value, and
maybe need something like relative positioning. The weird thing is
that I his page actually produces overlapped text on my browser
(Firefox 5.0) and inspection or the web page's source seems to indicate
that the executed code matches the code he published in a multi-line
text control, which is what I copied into my test.
we have no idea what MyFunction(3) ..
That's just some toy code so I remember the syntax for passing
parameters, etc. -- irrelevant to the subject problem.
You can try my own interactive positioning demo:


Thanks. I ran it a bit (successfully). I'm going to concentrate on
your code for a while instead of banging my head against his code.

The main thing is that I have introduced the html/css validation into
my practice. Again, I thank you for that.

Regards,
Richard

Apr 4 '06 #3
Richard wrote:
Gérard wrote:
top is -50; the validator will report this as an error. No units are
specified for top and left. So this is a parsing error.
That didn't happen for some reason.


Probably because the styles are declared in-line. I don't think either
the HTML or CSS validator checks in-line CSS.
The weird thing is
that I his page actually produces overlapped text on my browser
(Firefox 5.0) and inspection or the web page's source seems to indicate
that the executed code matches the code he published in a multi-line
text control, which is what I copied into my test.


Probably because the echoecho.com page in question is rendered in quirks
mode. If it had a proper DOCTYPE and rendered in standards mode, results
could very well be different.

The sample you found is indeed a terrible one. The fact that it
references Netscape's "poor CSS support" should make it obvious that the
article was written many years ago, at least to those of us who know it
is referring to Netscape 4. If the article were dated, you'd know how
old it really is, too.

Things have changed significantly since Netscape 4 was considered
"modern". This site hasn't kept up with the times, so you should leave
it. Forever.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Apr 4 '06 #4
Hi Kchayka,

Thanks for responding.
top is -50; the validator will report this as an error. No units are
specified for top and left. So this is a parsing error. That didn't happen for some reason.

Probably because the styles are declared in-line.


I saw the CSS validator announcement to that effect, so I put in a link
to an external .css file with ".aboveText ... and .belowText ..." in
it. But I see now that the problem was
in the <div> tag code, as Gerard pointed out. How can that be
validated by the CSS validator.
rendered in quirks mode.


I followed up on this at http://hsivonen.iki.fi/doctype/. That was a
great insight because it irritated me a lot. Just one more curiosity:
Is there something in his document that actually requests quirk mode?
That would be the final explanation for why his document and my snippet
extracted from it displayed differently.

Final word: PROBLEM SOLVED: As Gerard pointed out, unit were missing.
I added px in a couple of places, but not all!! I just noticed it now,
added the rest, and voila, the snippet presented itself just like the
web page! And "quirks" is the reason faulty code still works.

Thanks to all of you for educating me.

Regards,
Richard.

Apr 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
13
by: murali | last post by:
Hello everyone, I used absolute positioning with div tag in my website. The page looks cool as long as someone doesn't try to zoom in by increasing the text size (ctrl++ or thru changing font...
1
by: Chris McGarry | last post by:
Hello, I'm new to style sheets and have been fighting with browser compatibility for two days. I'm developing a image selection page (similar to Ebay where the visitor can select and enlarge 1-6...
8
by: rdlebreton | last post by:
Hi, Folks! I've been trying to develop my own version of these draggable layers and I have been limiting myself to IE6...for now. I have looked at some other examples to get ideas of creating...
17
by: George Hester | last post by:
http://tinyurl.com/5uj6w The lower middle icon the "block" should not drop down when the mouse is over it. How can I stop that? Also the navigation divs both top and bottom should follow the...
14
by: Bryan | last post by:
I am attempting to make a web page more Netscape friendly... <a href="http:www.gordonceilings.com"></a> I have already corrected the table issues in an offline staging site (where I do the...
6
by: | last post by:
I just installed VS 2005. Was working with 2003 and .Net 1.1. Trying to get the feel for a master page and I'm having some issues. I'm looking for a pretty basic setup. Standard header with an...
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
0
by: sknonline | last post by:
Greetings. I am having troubles using absolute positioning in IE6. When I establish the width as 100%, it's not spanning the entire width of the browser. It works in Firefox, Safari, and IE7.......
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.