473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

position: absolute

Hi,

I want to make a horizontal navigation with the second level beneath
the first level.
The items of the second level shall appear left aligned with their
corresponding first level item. To visualize it:

Entry1 Entry2 Entry3 Entry4
Entry3.1 Entry3.2 Entry3.3

The CMS always displays only the second level menu of the active first
level item.

At the moment I have the following structure (the second first level
item is active):

<span class="firstlevelitem">
<a><img></a>
</span>
<span class="firstlevelitem">
<a><img></a>
<div id="secondlevel">
<a><img></a>
<a><img></a>
</div>
</span>
<span class="firstlevelitem">
<a><img></a>
</span>

My stylesheet:
..firstlevelitem
{
position: relative;
}
#secondlevel
{
position: absolute;
top: 40px;
}

But this does not work. In IE the second level menu starts at that
horizontal position where the corresponding first level item _ends_ and
in FF the second level menu is in a position that I don't understand at
all (shifted to the right).

Why? Because I put a block element into an inline element?
How can I do it right?

Regards,
André

Oct 31 '06 #1
5 2056
On 2006-10-31, André Hänsel <an***@webkr.dewrote:
Hi,

I want to make a horizontal navigation with the second level beneath
the first level.
The items of the second level shall appear left aligned with their
corresponding first level item. To visualize it:

Entry1 Entry2 Entry3 Entry4
Entry3.1 Entry3.2 Entry3.3

The CMS always displays only the second level menu of the active first
level item.

At the moment I have the following structure (the second first level
item is active):

<span class="firstlevelitem">
<a><img></a>
</span>
<span class="firstlevelitem">
<a><img></a>
<div id="secondlevel">
<a><img></a>
<a><img></a>
</div>
</span>
<span class="firstlevelitem">
<a><img></a>
</span>

My stylesheet:
.firstlevelitem
{
position: relative;
}
#secondlevel
{
position: absolute;
top: 40px;
}

But this does not work. In IE the second level menu starts at that
horizontal position where the corresponding first level item _ends_ and
in FF the second level menu is in a position that I don't understand at
all (shifted to the right).
In FF I get

img img img
img img

isn't that what you intended?
Why? Because I put a block element into an inline element?
Putting div inside span is dodgy HTML.
How can I do it right?
The good news is CSS itself can perfectly well handle display: block
nested inside display: inline (technically what happens is you get
"anonymous block boxes"). So just replace span with div, and add
display: inline to the selector for .firstlevelitem. That may make some
browsers better behaved.
Oct 31 '06 #2
On 2006-10-31, André Hänsel <an***@webkr.dewrote:
Hi,

I want to make a horizontal navigation with the second level beneath
the first level.
The items of the second level shall appear left aligned with their
corresponding first level item. To visualize it:

Entry1 Entry2 Entry3 Entry4
Entry3.1 Entry3.2 Entry3.3

The CMS always displays only the second level menu of the active first
level item.

At the moment I have the following structure (the second first level
item is active):

<span class="firstlevelitem">
<a><img></a>
</span>
<span class="firstlevelitem">
<a><img></a>
<div id="secondlevel">
<a><img></a>
<a><img></a>
</div>
</span>
<span class="firstlevelitem">
<a><img></a>
</span>

My stylesheet:
.firstlevelitem
{
position: relative;
}
#secondlevel
{
position: absolute;
top: 40px;
}

But this does not work. In IE the second level menu starts at that
horizontal position where the corresponding first level item _ends_ and
in FF the second level menu is in a position that I don't understand at
all (shifted to the right).

Why? Because I put a block element into an inline element?
I had a look at this in Opera as well, where the situation is different
from that in Firefox.

The secondlevel div's containing block is the firstlevelitem it is
nested inside. It should be 40px from the top of that block.

FF puts it too low (I'm using my own image, however, which is probably a
different size from yours, so YMMV).

Opera puts it in the right place, vertically.

The much harder question for the UA, though, is what to use for the
computed value of "left" for the secondlevel div.

Because it's "auto" it should use the "static" position, which is
roughly where the image would have gone had it not been positioned.

The spec does however say, "But rather than actually calculating the
dimensions of that hypothetical box, user agents are free to make a
guess at its probable position." (See section 10.3.7 of CSS 2.1)

In this case this is particularly hard because had the box not been
positioned, things would have flowed quite differently. The box would
have created an anonymous block box and gone below and to the left, so
arguably both Opera and FF are wrong to indent it from the left at all.
But the spec does say they can "make a guess", which they have done.

We are in a horribly grey area here, but it can easily be avoided. Just
add left: 0px to your selector for #secondlevel. This makes the UA's job
a lot easier because it doesn't have to guess at that static position,
and hopefully you'll get more consistent results across browsers.
Oct 31 '06 #3
Hi,

I made a test case which you can get under
http://kundenweb.creations.de/usenet/index.zip.

In FF it looks like http://kundenweb.creations.de/usenet/ff.jpg and in
IE it looks like http://kundenweb.creations.de/usenet/ie.jpg.

It should be like in IE but the "D" of "Die gesamte Show" should be
under the "B" of "Buchbar".

Regards,
André
Ben C wrote:
On 2006-10-31, André*ˆä®³el <an***@webkr.dewrote:
Hi,

I want to make a horizontal navigation with the second level beneath
the first level.
The items of the second level shall appear left aligned with their
corresponding first level item. To visualize it:

Entry1 Entry2 Entry3 Entry4
Entry3.1 Entry3.2 Entry3.3

The CMS always displays only the second level menu of the active first
level item.

At the moment I have the following structure (the second first level
item is active):

<span class="firstlevelitem">
<a><img></a>
</span>
<span class="firstlevelitem">
<a><img></a>
<div id="secondlevel">
<a><img></a>
<a><img></a>
</div>
</span>
<span class="firstlevelitem">
<a><img></a>
</span>

My stylesheet:
.firstlevelitem
{
position: relative;
}
#secondlevel
{
position: absolute;
top: 40px;
}

But this does not work. In IE the second level menu starts at that
horizontal position where the corresponding first level item _ends_ and
in FF the second level menu is in a position that I don't understand at
all (shifted to the right).

In FF I get

img img img
img img

isn't that what you intended?
Why? Because I put a block element into an inline element?

Putting div inside span is dodgy HTML.
How can I do it right?

The good news is CSS itself can perfectly well handle display: block
nested inside display: inline (technically what happens is you get
"anonymous block boxes"). So just replace span with div, and add
display: inline to the selector for .firstlevelitem. That may make some
browsers better behaved.
Oct 31 '06 #4
On 2006-10-31, André Hänsel <an***@webkr.dewrote:
Hi,

I made a test case which you can get under
http://kundenweb.creations.de/usenet/index.zip.

In FF it looks like http://kundenweb.creations.de/usenet/ff.jpg and in
IE it looks like http://kundenweb.creations.de/usenet/ie.jpg.

It should be like in IE but the "D" of "Die gesamte Show" should be
under the "B" of "Buchbar".
Try adding left: 0px to #menu2 (as suggested in earlier post) to save
the UA guessing the static position.

Also always use the strict doctype for IE which is I think this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

Put it very first thing in the file, before <html>

So much for the horizontal position. If that doesn't work in IE after
you've tried those two things, then you're up against IE bugs and I
can't help you.

The differences in vertical position of "Die gesamte Showcase" etc. look
like they're to do with different placing of the top edge of the inline
box of "Buchbar" (that's the position that "Die gesamte" is offset by
42px from).

Where exactly the top edge of an inline box goes is something that's
also specified with some flexibility. So one would expect some variation
between browsers. I said in an earlier post that I thought Opera was
"right" and FF "wrong". I take that back. They're legitimately
different on this.

To get finer control, the best thing I can think of is to make .menuitem
float: left instead of display: inline. Then each menuitem is actually a
block box, with its top edge in a much more clearly specified place.
Oct 31 '06 #5
Hey,

both of your suggestions do exactly what you predicted - perfectly. :)

Thank you,
André

Ben C wrote:
On 2006-10-31, André*ˆä®³el <an***@webkr.dewrote:
Hi,

I made a test case which you can get under
http://kundenweb.creations.de/usenet/index.zip.

In FF it looks like http://kundenweb.creations.de/usenet/ff.jpg and in
IE it looks like http://kundenweb.creations.de/usenet/ie.jpg.

It should be like in IE but the "D" of "Die gesamte Show" should be
under the "B" of "Buchbar".

Try adding left: 0px to #menu2 (as suggested in earlier post) to save
the UA guessing the static position.

Also always use the strict doctype for IE which is I think this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

Put it very first thing in the file, before <html>

So much for the horizontal position. If that doesn't work in IE after
you've tried those two things, then you're up against IE bugs and I
can't help you.

The differences in vertical position of "Die gesamte Showcase" etc. look
like they're to do with different placing of the top edge of the inline
box of "Buchbar" (that's the position that "Die gesamte" is offset by
42px from).

Where exactly the top edge of an inline box goes is something that's
also specified with some flexibility. So one would expect some variation
between browsers. I said in an earlier post that I thought Opera was
"right" and FF "wrong". I take that back. They're legitimately
different on this.

To get finer control, the best thing I can think of is to make .menuitem
float: left instead of display: inline. Then each menuitem is actually a
block box, with its top edge in a much more clearly specified place.
Nov 2 '06 #6

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

Similar topics

4
by: Peter Fjelsten | last post by:
Guys at comp.infosystems.www.authoring.stylesheets, I have designed a page in (x)HTML transitional that I am happy with in (close to) standard compliant browsers (i.e. Firebird/Opera), but IE...
1
by: J. Potts | last post by:
Just out of curiosity, has anyone run into this problem? Someone where I work put a set of pages together with the following in the style sheet: BODY { position: absolute; margin-top: 0mm;...
5
by: CMAR | last post by:
I have been having a problem styling a page, which you can see live at my test site: Designer Page (http://home.ne.rr.com/thespar/) (Ignore the missing pictures, which have not been uploaded.)...
7
by: DaWoE | last post by:
Hi, I want to place a div centered of another div in IE. I get this to work in Mozilla, but not in IE. The code i use for mozilla is the following : <html> <head> <style type="text/css">
1
by: dale zhang | last post by:
Hi, I have a web form page. it has gridlayout and a table at top like a template. When I have the literal or requiredfieldvalidator ErrorMsg displayed, they are all over the page. Is there...
3
by: moondaddy | last post by:
I'm trying to create my first user control and its function is to replace the use of a frames page. I want to position it under the pages header menus and to the right of the pages contents menus....
19
by: wmanzo | last post by:
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up...
6
by: ThunderMusic | last post by:
Hi, I think the subject says it all... thanks ThunderMusic
2
by: agbee1 | last post by:
Hello: I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
0
by: crisscross27 | last post by:
Hi, I found a page called "myflashfetish" where you chan choose mp3 players for my space, well the problem is this, I wanted to place 2 or more players in myspace in a particular place, I read...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.