This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > September 2005 > Why is my menu off-center?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Why is my menu off-center?
|
|
| Pierre Jelenc 2005-09-19, 11:20 pm |
|
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
| |
|
| 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
| |
| Roy Schestowitz 2005-09-20, 4:24 am |
| __/ [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
| |
| boclair 2005-09-20, 7:26 am |
| 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
| |
|
| Roy Schestowitz wrote:
[...]
> __/ [RobG] on Tuesday 20 September 2005 05:52 \__
>
>
>
>
>
> 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
| |
| Pierre Jelenc 2005-09-20, 7:40 pm |
| boclair <boclair@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
| |
| Jim Moe 2005-09-20, 7:40 pm |
| 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)
| |
| Pierre Jelenc 2005-09-20, 11:28 pm |
| Jim Moe <jmm-list.AXSPAMGN@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
| |
| Roy Schestowitz 2005-09-21, 7:20 am |
| __/ [RobG] on Tuesday 20 September 2005 09:41 \__
> Roy Schestowitz wrote:
> [...]
>
> 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
| |
| Jim Moe 2005-09-21, 7:34 pm |
| Pierre Jelenc wrote:
>
>
> 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)
| |
| Pierre Jelenc 2005-09-22, 4:23 am |
| Roy Schestowitz <newsgroups@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
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|