Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > center menu in css

Reply
Thread Tools

center menu in css

 
 
Julien
Guest
Posts: n/a
 
      01-28-2009
Hello,
I have a menu in css with position absolute, i have put auto for margin
right and left and put it un a global div but my menu stay on the left.
Could someone help me ?

Here is the partial CSS code :

body {
background-color: #000000;
background-image: url(images/top.png);
background-repeat: no-repeat;
background-position: top center;
text-align: center;
margin: 0;

#global {
position: relative;
margin-left: auto;
margin-right: auto;
width: 1024px;
text-align: left;
}

#menu {
position: absolute;
top: 251px;
width: 743px;
right: auto;
left: auto;
}

And here is the partial html code :

<div id="global"> <a name="haut" id="haut"></a>
<div id="menu">
(...)
</div>
 
Reply With Quote
 
 
 
 
Julien
Guest
Posts: n/a
 
      01-28-2009
Ben C a écrit :
> On 2009-01-28, Julien <> wrote:
>> Hello,
>> I have a menu in css with position absolute, i have put auto for margin
>> right and left and put it un a global div but my menu stay on the left.
>> Could someone help me ?

>
> You need to set left and right both to 0.
>
> [...]
>> #menu {
>> position: absolute;
>> top: 251px;
>> width: 743px;
>> right: auto;
>> left: auto;
>> }

>
> You don't seem to have actually set margin to auto. What you need is
> something more like this:
>
> #menu {
> position: absolute;
> top: 251px;
> width: 743px;
> right: 0;
> left: 0;
> margin-left: auto;
> margin-right: auto;
> }


With that, the menu is at 0px on the left, it's not working then.
 
Reply With Quote
 
 
 
 
Julien
Guest
Posts: n/a
 
      01-28-2009
Ben C a écrit :
> On 2009-01-28, Julien <> wrote:
>> Hello,
>> I have a menu in css with position absolute, i have put auto for margin
>> right and left and put it un a global div but my menu stay on the left.
>> Could someone help me ?

>
> You need to set left and right both to 0.
>
> [...]
>> #menu {
>> position: absolute;
>> top: 251px;
>> width: 743px;
>> right: auto;
>> left: auto;
>> }

>
> You don't seem to have actually set margin to auto. What you need is
> something more like this:
>
> #menu {
> position: absolute;
> top: 251px;
> width: 743px;
> right: 0;
> left: 0;
> margin-left: auto;
> margin-right: auto;
> }


Sorry, I said margin but it's didn't what i wanted to say.
I just wanted to say i set righ and left "space" to auto.
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      01-28-2009
On 28 Jan 2009, Julien <> wrote:

> Hello,
> I have a menu in css with position absolute, i have put auto for margin
> right and left and put it un a global div but my menu stay on the left.
> Could someone help me ?
>
> Here is the partial CSS code :
> * snip
> And here is the partial html code :
> * snip


Here's the whole answer. Post a url, not snippets.

--
Neredbojias
http://www.neredbojias.org/
http://www.neredbojias.net/
The road to Heaven is paved with bad intentions.
 
Reply With Quote
 
Julien
Guest
Posts: n/a
 
      01-28-2009
Ben C a écrit :
> On 2009-01-28, Julien <> wrote:
>> Ben C a écrit :
>>> On 2009-01-28, Julien <> wrote:
>>>> Hello,
>>>> I have a menu in css with position absolute, i have put auto for margin
>>>> right and left and put it un a global div but my menu stay on the left.
>>>> Could someone help me ?
>>> You need to set left and right both to 0.
>>>
>>> [...]
>>>> #menu {
>>>> position: absolute;
>>>> top: 251px;
>>>> width: 743px;
>>>> right: auto;
>>>> left: auto;
>>>> }
>>> You don't seem to have actually set margin to auto. What you need is
>>> something more like this:
>>>
>>> #menu {
>>> position: absolute;
>>> top: 251px;
>>> width: 743px;
>>> right: 0;
>>> left: 0;
>>> margin-left: auto;
>>> margin-right: auto;
>>> }

>> Sorry, I said margin but it's didn't what i wanted to say.
>> I just wanted to say i set righ and left "space" to auto.

>
> Yes, but that's not how you centre a positioned box. There's no rule
> that says "solve for left and right under the constraint that they get
> equal values". The browser solves for right if direction is ltr
> otherwise for left.
>
> See http://www.w3.org/TR/CSS21/visudet.h...replaced-width
>
> You centre therefore with margins and left and right set to 0 as I
> explained.


It works on Firefox but not on my IE 6, you can check here :
http://www.move-france.fr/index2.php
 
Reply With Quote
 
Julien
Guest
Posts: n/a
 
      01-28-2009
Neredbojias a écrit :
> On 28 Jan 2009, Julien <> wrote:
>
>> Hello,
>> I have a menu in css with position absolute, i have put auto for margin
>> right and left and put it un a global div but my menu stay on the left.
>> Could someone help me ?
>>
>> Here is the partial CSS code :
>> * snip
>> And here is the partial html code :
>> * snip

>
> Here's the whole answer. Post a url, not snippets.
>


I don't post url because there is things that will probably bore you
instead of wishing to help but as you requested, i have put an url on my
other reply.
 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      01-28-2009
Julien wrote:

> http://www.move-france.fr/index2.php


Increase your user defined font size one click and admire how the menu wraps
onto the next line and the submenus overlay the other text.


 
Reply With Quote
 
John Hosking
Guest
Posts: n/a
 
      01-28-2009
Julien wrote:
> Ben C a écrit :
>> On 2009-01-28, Julien <> wrote:
>>> Ben C a écrit :
>>>> On 2009-01-28, Julien <> wrote:
>>>>> Hello,
>>>>> I have a menu in css with position absolute, i have put auto for
>>>>> margin right and left and put it un a global div but my menu stay
>>>>> on the left.
>>>>> Could someone help me ?
>>>> You need to set left and right both to 0.
>>>>
>>>> [...]
>>>>> #menu {
>>>>> position: absolute;
>>>>> top: 251px;
>>>>> width: 743px;
>>>>> right: auto;
>>>>> left: auto;
>>>>> }
>>>> You don't seem to have actually set margin to auto. What you need is
>>>> something more like this:
>>>>
>>>> #menu {
>>>> position: absolute;
>>>> top: 251px;
>>>> width: 743px;
>>>> right: 0;
>>>> left: 0;
>>>> margin-left: auto;
>>>> margin-right: auto;
>>>> }
>>> Sorry, I said margin but it's didn't what i wanted to say.
>>> I just wanted to say i set righ and left "space" to auto.

>>
>> Yes, but that's not how you centre a positioned box. There's no rule
>> that says "solve for left and right under the constraint that they get
>> equal values". The browser solves for right if direction is ltr
>> otherwise for left.
>>
>> See http://www.w3.org/TR/CSS21/visudet.h...replaced-width
>>
>> You centre therefore with margins and left and right set to 0 as I
>> explained.

>
> It works on Firefox but not on my IE 6, you can check here :
> http://www.move-france.fr/index2.php


Thanks for the URL but, in future, it's better to provide one with a
simplified example of whatever you're asking about.

It'd be *especially* better to provide a page without that noise that
starts up automatically. Where's the damned OFF button?

We don't need to see all that JS, either.

Nor the frames and ads. Seems we're really looking at
http://electropica.free.fr/index2.php in the end.

I changed your rulest for #global to simply

#global { position: relative; }

in FF2 using Web Developer, and your menu stayed centered after that.
What's more, it stayed aligned with the background bevel as I resized
the viewport, which it didn't do in FF before. (All of this is only at
the font size you specify; when I try to upsize even one notch, the menu
breaks.

I didn't test this in IE6, but you're welcome to try it and see how it
works for you.

Why dl, dt, and dd for your menu? What are you defining?

Why JavaScript for your links? Wouldn't you like the links indexed by
search engines (and usable by human visitors without JS)?

HTH. Bon chance.

--
John
Possessive "its" has no apostrophe. Even on the Internet.
 
Reply With Quote
 
Julien
Guest
Posts: n/a
 
      01-29-2009
John Hosking a écrit :
> Julien wrote:
>> Ben C a écrit :
>>> On 2009-01-28, Julien <> wrote:
>>>> Ben C a écrit :
>>>>> On 2009-01-28, Julien <> wrote:
>>>>>> Hello,
>>>>>> I have a menu in css with position absolute, i have put auto for
>>>>>> margin right and left and put it un a global div but my menu stay
>>>>>> on the left.
>>>>>> Could someone help me ?
>>>>> You need to set left and right both to 0.
>>>>>
>>>>> [...]
>>>>>> #menu {
>>>>>> position: absolute;
>>>>>> top: 251px;
>>>>>> width: 743px;
>>>>>> right: auto;
>>>>>> left: auto;
>>>>>> }
>>>>> You don't seem to have actually set margin to auto. What you need is
>>>>> something more like this:
>>>>>
>>>>> #menu {
>>>>> position: absolute;
>>>>> top: 251px;
>>>>> width: 743px;
>>>>> right: 0;
>>>>> left: 0;
>>>>> margin-left: auto;
>>>>> margin-right: auto;
>>>>> }
>>>> Sorry, I said margin but it's didn't what i wanted to say.
>>>> I just wanted to say i set righ and left "space" to auto.
>>>
>>> Yes, but that's not how you centre a positioned box. There's no rule
>>> that says "solve for left and right under the constraint that they get
>>> equal values". The browser solves for right if direction is ltr
>>> otherwise for left.
>>>
>>> See http://www.w3.org/TR/CSS21/visudet.h...replaced-width
>>>
>>> You centre therefore with margins and left and right set to 0 as I
>>> explained.

>>
>> It works on Firefox but not on my IE 6, you can check here :
>> http://www.move-france.fr/index2.php

>
> Thanks for the URL but, in future, it's better to provide one with a
> simplified example of whatever you're asking about.
>
> It'd be *especially* better to provide a page without that noise that
> starts up automatically. Where's the damned OFF button?
>
> We don't need to see all that JS, either.
>
> Nor the frames and ads. Seems we're really looking at
> http://electropica.free.fr/index2.php in the end.
>
> I changed your rulest for #global to simply
>
> #global { position: relative; }
>
> in FF2 using Web Developer, and your menu stayed centered after that.
> What's more, it stayed aligned with the background bevel as I resized
> the viewport, which it didn't do in FF before. (All of this is only at
> the font size you specify; when I try to upsize even one notch, the menu
> breaks.
>
> I didn't test this in IE6, but you're welcome to try it and see how it
> works for you.
>
> Why dl, dt, and dd for your menu? What are you defining?
>
> Why JavaScript for your links? Wouldn't you like the links indexed by
> search engines (and usable by human visitors without JS)?
>
> HTH. Bon chance.
>


I don't understand well what you are saying...
You say to just write :
#global { position: relative; }
instead of what i have ?

What do you say about the menu that fall after loading ?

For dl, dt and dd, its the style of the menu.
As it's the same as the main style, it's useless.

For the link, i use that style to avoid the player to get reload and I
didn't wanted to use frame.
 
Reply With Quote
 
Julien
Guest
Posts: n/a
 
      01-29-2009
John Hosking a écrit :
> Julien wrote:
>> Ben C a écrit :
>>> On 2009-01-28, Julien <> wrote:
>>>> Ben C a écrit :
>>>>> On 2009-01-28, Julien <> wrote:
>>>>>> Hello,
>>>>>> I have a menu in css with position absolute, i have put auto for
>>>>>> margin right and left and put it un a global div but my menu stay
>>>>>> on the left.
>>>>>> Could someone help me ?
>>>>> You need to set left and right both to 0.
>>>>>
>>>>> [...]
>>>>>> #menu {
>>>>>> position: absolute;
>>>>>> top: 251px;
>>>>>> width: 743px;
>>>>>> right: auto;
>>>>>> left: auto;
>>>>>> }
>>>>> You don't seem to have actually set margin to auto. What you need is
>>>>> something more like this:
>>>>>
>>>>> #menu {
>>>>> position: absolute;
>>>>> top: 251px;
>>>>> width: 743px;
>>>>> right: 0;
>>>>> left: 0;
>>>>> margin-left: auto;
>>>>> margin-right: auto;
>>>>> }
>>>> Sorry, I said margin but it's didn't what i wanted to say.
>>>> I just wanted to say i set righ and left "space" to auto.
>>>
>>> Yes, but that's not how you centre a positioned box. There's no rule
>>> that says "solve for left and right under the constraint that they get
>>> equal values". The browser solves for right if direction is ltr
>>> otherwise for left.
>>>
>>> See http://www.w3.org/TR/CSS21/visudet.h...replaced-width
>>>
>>> You centre therefore with margins and left and right set to 0 as I
>>> explained.

>>
>> It works on Firefox but not on my IE 6, you can check here :
>> http://www.move-france.fr/index2.php

>
> Thanks for the URL but, in future, it's better to provide one with a
> simplified example of whatever you're asking about.
>
> It'd be *especially* better to provide a page without that noise that
> starts up automatically. Where's the damned OFF button?
>
> We don't need to see all that JS, either.
>
> Nor the frames and ads. Seems we're really looking at
> http://electropica.free.fr/index2.php in the end.
>
> I changed your rulest for #global to simply
>
> #global { position: relative; }
>
> in FF2 using Web Developer, and your menu stayed centered after that.
> What's more, it stayed aligned with the background bevel as I resized
> the viewport, which it didn't do in FF before. (All of this is only at
> the font size you specify; when I try to upsize even one notch, the menu
> breaks.
>
> I didn't test this in IE6, but you're welcome to try it and see how it
> works for you.
>
> Why dl, dt, and dd for your menu? What are you defining?
>
> Why JavaScript for your links? Wouldn't you like the links indexed by
> search engines (and usable by human visitors without JS)?
>
> HTH. Bon chance.
>


I tried to clean the style to make it a defaut but it's still the same,
i don't know what where i'm wrong.

http://electropica.free.fr/index1.php

(still with the useless script, i won't remove everything in case it
works well to not have to put again in place)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjust Menu to the center colleen1980@gmail.com Javascript 2 08-24-2008 04:18 PM
How to properly center this menu Yogi_Bear_79 HTML 8 11-29-2006 02:49 AM
CSS MENU and CSS photo gallery desjardins.daniel@gmail.com Javascript 1 02-19-2006 06:22 PM
Naming of core NASA center with the words "Mission Control Center" & mass use of religious anthem sounding word "Mission" in Context of Space Exploration & the Moon Landing Hoax moonlandinghoaxreligious@yahoo.com Digital Photography 0 09-27-2005 08:28 PM
Re: [css] center brucie HTML 0 06-22-2003 08:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57