WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Solution how to center a horizontal Show_Menu2 menu (all css 2)
  • Print
Pages: [1]   Go Down

Author Topic: Solution how to center a horizontal Show_Menu2 menu (all css 2)  (Read 8358 times)

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Solution how to center a horizontal Show_Menu2 menu (all css 2)
« on: June 01, 2010, 09:53:43 PM »
Hi there,

On several topics I read there were problems regarding centering a horizontal menu but no solutions.

I did some testing on the SM2 menu of the ALL CSS 2 template and found the solution.

Go to the css and find:

Code: [Select]
#nav {
height: 1.68em;
background: #666;
border-top: 0;
border-bottom: 1px solid #000;
padding:0;
}
#nav ul {
list-style-type: none;
margin: 0;
padding: 0;
font-size: 81%;
text-transform: uppercase;
width: auto;


Change it into:

Code: [Select]
#nav {
height: 34px;
float:right;
position:relative;
        left:-50%;
}
#nav ul {
list-style-type: none;
margin: 0;
padding: 0;
font-size: 11px;
width: auto;
left:50%;

There are 2 real changes (forget the other ones. They're just personal changes):

In #nav put this code:

float:right;
position:relative;   
left:-50%;


In #nav ul put this code:

left:50%;

If you use submenu's then just put in the 2nd Child menu under #nav .menu li ul the following:
left:-25%;

With the submenu's it's just playing with the "left" css style.

Hope this helps for you.

Boudi
« Last Edit: June 01, 2010, 10:19:37 PM by Boudi »
Logged
...:: Bake the Unbakable ::...

Argos

  • Guest
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #1 on: June 09, 2010, 11:04:58 AM »
I didn't try, and just out of curiousity: isn't it also possible to just add a container DIV around the nav, with style "text-align: center"? Or with style "margin: 0 auto"?
Logged

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #2 on: June 09, 2010, 11:24:03 AM »
Quote
isn't it also possible to just add a container DIV around the nav, with style "text-align: center"? Or with style "margin: 0 auto"?

First I thought it was indeed that simple but it isn't. I already tried your solutions too but the <div> solutions don't work. They will be overwritten by the css. Besides that you have to deal with the submenu's too when you center the whole thing because they have seperate css calls.

I have a working example [here] (still in testmodus). As you see it's fully centered and the submenu's are too. (even tested with sub-submenu's and that worked great)

Boudi
Logged
...:: Bake the Unbakable ::...

Argos

  • Guest
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #3 on: June 09, 2010, 11:30:02 AM »
Nice work! I actually never thought about centering a menu, but it looks nice for a change. How would it look to center the text within the LI's as well? Nice, or a bit messy?
Logged

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #4 on: June 09, 2010, 11:34:48 AM »
Thnq :)

I'm not sure to center the text too. I think I leave it this way but may be I'm thinking different this afternoon *lol*  :lol:

Well I acutally build the (external) webshop first. The menu of this shop is centered. After that the client wanted the website build with the same style as the webshop. So I had to center the menu too. So this website and webshop are completely 2 different scripts (WB and Cubecart) but overall they share the same look :)

« Last Edit: June 09, 2010, 11:36:48 AM by Boudi »
Logged
...:: Bake the Unbakable ::...

Offline dbs

  • Betatester
  • **
  • Posts: 8914
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #5 on: June 09, 2010, 11:53:39 AM »
something ist wrong with your nav.
firebug says:
Code: [Select]
#nav {
float:left;
height:34px;
}
is all you need to center the nav.

but normally ist div with text-align center the right way.
like here: *removed*

dbs
« Last Edit: June 22, 2010, 07:50:32 PM by dbs »
Logged
https://onkel-franky.de

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #6 on: June 09, 2010, 11:58:44 AM »
Hi,

Thnq for responding.

Quote
but normally ist div with text-align center the right way.

You're totally right and that was one of my first tries too but it simply doesn't work with the ALL CSS 2 menu and submenu style.

Creating a menu in the center is no problem. Creating one with sub(submenu's) is another thing. And that's why I put this solution down here :)

Boudi.
Logged
...:: Bake the Unbakable ::...

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #7 on: June 14, 2010, 10:41:22 PM »
It is centred nicely, congrats on figuring it out.

I do hope that the example site link is not supposed to be all working because the drop-downs seem badly broken in IE7. Not sure, might be just because of the rotating banner.
The "behandelingen" menu somestimes only shows the first item on the drop-down instead of the full drop-down list when the rotating highlight is on the first point and on all of them only the first item on the menu can be picked as the menu disappears when the mouse goes further down.

Can't see the sub-submenu's you mentioned, probably due to the last point.
Logged

Offline Boudi

  • Posts: 1190
  • Gender: Male
  • //o_-\\
    • Yze Webdesign
Re: Solution how to center a horizontal Show_Menu2 menu (all css 2)
« Reply #8 on: June 14, 2010, 10:48:32 PM »
Quote
because the drop-downs seem badly broken in IE7

You're right. I only checked it with IE8 and FF. But I think this can be easy fixed with a z-index. Thnq for noticing!

Sub-submenu's I did test and it works fine. But for this website They were not needed.

Regarding the sub- and subsubmenu's:

If you use submenu's then just put in the 2nd Child menu under #nav .menu li ul the following:
left:-25%;

With the submenu's it's just playing with the "left" css style.


UPDATE: Works well under IE7 too now (placed a z-index)
« Last Edit: June 15, 2010, 11:23:20 AM by Boudi »
Logged
...:: Bake the Unbakable ::...

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Solution how to center a horizontal Show_Menu2 menu (all css 2)
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2