473,834 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2056
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*****@bigpon d.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="bottomnavba r">
...
</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

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

Similar topics

10
2147
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: <script>IncludeMenuHere()</script> More, any tips about "fading" the menu item in and out (x-browser)? Currently it's using DIVs and this.items.visibility(false);
7
3003
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? Any help appreciated. John In the below script, I can expand and contract the nodes when clicked on, but I want the menu to close all other siblings to the node clicked so that only one sub menu option is expanded at one time. If the node...
6
2740
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="" border="0" src="fold.gif">Club&nbsp;Links</a><br> <div id="club_s" class="off"> <a href="articles.htm" target="main">Articles/Cartoons</a><br> <a href="photo1.htm" target="main">Astro&nbsp;Images</a><br> <a href="links.htm"...
18
3543
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 help section, this has brought me here. The script can be found at http://simplythebest.net/scripts/DHTML_scripts/dhtml_script_100.html (no login or anything required... I just thought the script might be too long to repost here)
5
5325
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 http://www.developersdex.com ***
2
2847
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 don't mean a drop-down or a pop-up menu, but those options which yield to another batch of sub-options when scrolled over, (as for example, the File->New option from internet explorer).
2
5612
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"> <div> <asp:Menu ID="Menu1" runat="server" BackColor="#FFC080" BorderColor="Olive" BorderStyle="Ridge" BorderWidth="1px" ForeColor="Navy"> <Items>
3
17047
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 the beginning of my application using VBA and then switch it back on within the exit routine of my application ?
3
2116
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 anyone recommend how to get started? Is there an Ajax control available for this or would more a basic javascript work just as well. I'm assuming I just need a div element that is shown on a mouse over, but I'm not sure how to go about aligning all...
5
2416
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 Edit options. File will be the same on both, but Edit will have different options. When I create an Edit menu on the custom menu bar, and then modify it, it seems to also be changing the Edit menu on the other custom menu,
0
9796
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9643
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10503
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10544
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10214
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.