473,405 Members | 2,421 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,405 software developers and data experts.

Why is my menu off-center?


The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.

Both HTML and CSS validate fine (there are some warnings on the CSS having
to do with color, but that's deliberate for the way I set the text
colors.)

Any idea what's happening?

Thanks,

Pierre
--
Pierre Jelenc | New on Home Office Records: Ethan Lipton
| www.homeofficerecords.com www.ethanlipton.com
The Gigometer | Pepper Of The Earth: the HO blog
www.gigometer.com | www.homeofficerecords.com/blog
Sep 19 '05 #1
10 2032
Pierre Jelenc wrote:
The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.


Get rid of the 50px margin-left/right.

[...]

--
Rob
Sep 20 '05 #2
__/ [Pierre Jelenc] on Tuesday 20 September 2005 00:30 \__

The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.

Both HTML and CSS validate fine (there are some warnings on the CSS having
to do with color, but that's deliberate for the way I set the text
colors.)

Any idea what's happening?

Thanks,

Pierre

There is a way of forcing divs to lie in the centre using some negative
values, but I could not find a reference. What you are trying to do will
not work in the Mozilla renderer. The margin-right will be ignored. You can
either compromise and go for:

"margin-left: 50px; width: 90%;"

which in practice looks quite OK if I reside the window quite widely. Also,
consider adding two fixed-sized divs to the left and the right of your
menu. Not elegant, but does the trick

__/ [RobG] on Tuesday 20 September 2005 05:52 \__

Get rid of the 50px margin-left/right.

[...]


This doesn't appear to be "doing the trick" in Firefox.
Roy

--
Roy S. Schestowitz | "Free the mind, the source will follow"
http://Schestowitz.com | SuSE Linux | PGP-Key: 74572E8E
7:35am up 25 days 19:49, 3 users, load average: 1.22, 0.65, 0.44
Sep 20 '05 #3
Pierre Jelenc wrote:
The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.


Set width rule at less than 100%, say 90%, and set the left rule at half
of that, say 5%

This will render as you wish in Moz but IE does not honour position fixed.

You could get something cross browser by using position absolute instead
but this may result in other problems according to page length.

Louise
Sep 20 '05 #4
Roy Schestowitz wrote:
[...]
__/ [RobG] on Tuesday 20 September 2005 05:52 \__
Get rid of the 50px margin-left/right.

[...]

This doesn't appear to be "doing the trick" in Firefox.


Depends on the trick! :-)

If the 'menu' was the string of buttons, then yes it did for me in
Firefox. But if the green-bordered div is the menu, then it extends for
the width of the page, which may not be the right trick. :-o

--
Rob
Sep 20 '05 #5
boclair <bo*****@bigpond.net.au> writes:

Set width rule at less than 100%, say 90%, and set the left rule at half
of that, say 5%
Thanks, that could work unless the window is very narrow: in some pages I
will have a 50-pixel wide motif running down the edge on either the left
or the right.
This will render as you wish in Moz but IE does not honour position fixed.
But it will then place the menu at its logical position according to
where the div is in the HTML code, right? Bottom of the page rather than
bottom of the window, for instance.
You could get something cross browser by using position absolute instead
but this may result in other problems according to page length.


Page length will be very variable, not only from page to page but also
temporally on some pages such as a show calendar. The menu does not have
to be in the same place across browsers, though.

Thanks to all.

Pierre
--
Pierre Jelenc | New on Home Office Records: Ethan Lipton
| www.homeofficerecords.com www.ethanlipton.com
The Gigometer | Pepper Of The Earth: the HO blog
www.gigometer.com | www.homeofficerecords.com/blog
Sep 20 '05 #6
Pierre Jelenc wrote:
The demo page at http://www.robschwimmer.com/tmp/test.html has a menu at
the bottom, which should be centered 50 pixels from both left and right
edges. As the dotted green line around the enclosing div indicates, it is
--in Mozilla at least-- actually pushed to the right.

Wrap the nav div in another div that does the positioning:
#place-the-bar { border: 1px solid white;
position: fixed;
z-index: 100;
bottom: 0;
width: 100%;
}
#bottomnavbar {
border: dotted green medium;
margin-left: 50px; margin-right: 50px;margin-top: 5px;
padding-bottom: 10px; padding-top: 10px;
text-align: center;
background-color: #333;
}

...

<div id="place-the-bar">
<div id="bottomnavbar">
...
</div>
</div>

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 20 '05 #7
Jim Moe <jm***************@sohnen-moe.com> writes:

Wrap the nav div in another div that does the positioning:


Thanks! The problem is then only when the problematic div is contained
directly in the body? Is there any reason why I should not systematically
put a "wrapper" div in all pages to remove this problem?

Pierre
--
Pierre Jelenc | New on Home Office Records: Ethan Lipton
| www.homeofficerecords.com www.ethanlipton.com
The Gigometer | Pepper Of The Earth: the HO blog
www.gigometer.com | www.homeofficerecords.com/blog
Sep 21 '05 #8
__/ [RobG] on Tuesday 20 September 2005 09:41 \__
Roy Schestowitz wrote:
[...]
__/ [RobG] on Tuesday 20 September 2005 05:52 \__
Get rid of the 50px margin-left/right.

[...]

This doesn't appear to be "doing the trick" in Firefox.


Depends on the trick! :-)

If the 'menu' was the string of buttons, then yes it did for me in
Firefox. But if the green-bordered div is the menu, then it extends for
the width of the page, which may not be the right trick. :-o


I think the intention was for the box to have buffers of fixed size... don't
ask me why...

Roy

--
Roy S. Schestowitz | Useless fact: Sharks are immune to cancer
http://Schestowitz.com | SuSE Linux | PGP-Key: 74572E8E
9:25am up 26 days 21:39, 3 users, load average: 0.10, 0.14, 0.46
Sep 21 '05 #9
Pierre Jelenc wrote:
Wrap the nav div in another div that does the positioning:


Thanks! The problem is then only when the problematic div is contained
directly in the body? Is there any reason why I should not systematically
put a "wrapper" div in all pages to remove this problem?

To be honest, I do not know why wrapping the div worked. But to achieve
the layout you are after, yes, use the two step div: one for position, one
for layout.
It would seem that margin and padding have a different origin reference
when position:fixed or :absolute is indicated. (Maybe if I became less
lazy and read the spec....)

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 21 '05 #10
Roy Schestowitz <ne********@schestowitz.com> writes:

I think the intention was for the box to have buffers of fixed size... don't
ask me why...


There's a vertical border down the side; or there will be. Therefore I
need the menu box to keep left and right margins free.

Pierre
--
Pierre Jelenc | New on Home Office Records: Ethan Lipton
| www.homeofficerecords.com www.ethanlipton.com
The Gigometer | Pepper Of The Earth: the HO blog
www.gigometer.com | www.homeofficerecords.com/blog
Sep 22 '05 #11

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

Similar topics

10
by: Gernot Frisch | last post by:
Hi, I have found some menu functions. It works quite well, but how can I replace it with a simple <a href> if javascript is turned off? I reduced my code to:...
7
by: johkar | last post by:
I am confused on childNodes or children. When you have nested lists, I would think it would all be one list in the Dom, this doesn't seem to be the case. So how do you traverse an unordered list?...
6
by: Dennis Allen | last post by:
Hi. I was wondering if someone here could help me. My web site has a very simple folder tree menu bar. Example: <a id="club_t" href="##" onclick="return Outline(this)"><img id="club_i" alt=""...
18
by: Andromeda | last post by:
I've been trying to add a tree menu to my website with some luck (more or less). I came across a script on simplythebest.net, but I seem to be having a problem with it... and since they have no...
5
by: Nothing | last post by:
Is there a way to turn off the defult menu bar? I do not want the user to see the File, Edit, View, etc. menu. How do you turn it off? Michael Charney *** Sent via Developersdex...
2
by: ishtar2020 | last post by:
Hi everybody I'd appreciate some help on creating a tear off menu with TkInter. I've been reading some documentation but still no luck. Please don't get confused: when I mean "tear off" menu I...
2
by: jason | last post by:
Does anybody know how I would get borders around each menuitem? Do I have incorportate into a table? Thanks. The below produces a border around the entire menu. <form id="form1" runat="server">...
3
by: prakashwadhwani | last post by:
When my application starts 2 toolbars still remain open 1) Form View and 2) Formatting (Form/Report) Toolbar Also ... Access's default Menu-Bar also remains open. How to switch it off at...
3
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can...
5
by: lorirobn | last post by:
Hi, I am trying to create two custom menu bars for my application, one for read-only users (without delete record), and one for update-access users (with delete record). I only need File and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.