Guys

am new searched around these forums

How do I make sure "nice menus" are in the centre of the page, they tend to be relatively on the left of the footer. I am using Andreas03 theme

Thank you

Comments

droople’s picture

While at that, how do I remove the "read more" from my home page content

Thank you

spamjim’s picture

This readme file includes formatting directions.

You can also modify the position as an admin in the 'blocks' section.

For precise position, you need to edit your theme template. There are easily searched articles on this site about editing themes.

anner’s picture

nicemenus relies heavily on css, so I centered and did all my tweaks in the nicemenus style.css file.

jmarkantes’s picture

Can you post your website or nice_menu.css so we can see the changes you did? I'm usually pretty decent with css, but am struggling also to get a horizontal nice-menu to center in the header. Also I'm trying to do it in my style.css, so future updates to nice-menu do not overwrite my css changes.

So far I've made some minor changes to the template, and then did a lot of changes to the style.css affecting the nice-menu elements. I just recently started really going through the nice-menu.css to see what may be forcing things to be more difficult to figure out. And, of course, already searched drupal.org and went through this and this with no luck (either no solution or a less than ideal solution).

J

droople’s picture

Here it is

I would like to centre the bottom nice menus

Thank you

anner’s picture

I can't post my site, because it's a secure intranet, but I can post my css. I'll try to do that tomorrow morning (sorry for the delay). Mine isn't exactly centered, just shoved over some because centering it didn't push it over far enough for me. I wanted to clear the left side menu. It took some fiddling and shows differently in IE and firefox.

Also, you can't make the changes in style.css, the module css will always override your theme css. You'll just need to remember to keep a copy of the nice_menu.css on upgrade so you can use that or redo your changes in the new one.

wolfraem’s picture

In order to change the CSS for Nice_Menu, copy nicemenu.css to your sites/all/themes/xxx/ folder and edit the copy there. The module will override the default css file if one exists in the themes folder. That way you

  1. don't have to completely reinstall the module if you screw up the css file, and
  2. don't have to worry about your hard work being erased if you update the module.

In fact, all modules should override the *.css files in their native directories if one exists in the current theme menu, so all custom module theming (that isn't done in the theme's style.css) should be conducted this way.

weisswolfen’s picture

I have the same problem i like to have the horizontal menu centered, not left as it is now, I went to change the css. in

-nice-menus.css

{.block-nice_menus{
line-height: normal;
/*font-size: normal;*/
/*position: relative;*/
z-index: 10;
position:relative;
left:100px;
}
DIDN'T WORK.

-themes/fancy/style.css

#menu {
margin:0 0 0 0 ;
padding: 5px 0.5em 0em 0.5em;
text-align: right;
vertical-align: top;
position:relative;
left:100px;
}

DIDN'T WORK

Where else I have to go to get this menu center positioned?

jmarkantes’s picture

I ended up padding one side with a percentage, instead of trying to align the text. The key line:

#block-nice_menus-1 {
padding-left:22%;

Doesn't seem quite as ideal, but it works.

Jason

drupalman1’s picture

thank you man, i used this and it worked.. good enough!

anner’s picture

This nice_menus.css centered things for me in firefox:

.block-nice_menus {
line-height: normal;
/*font-size: normal;*/
position: relative;
/*z-index: 10;
%float: left;*/
left: 14%;
}

/* need this to enable hidding inner span */
.block-nice_menus h2.title {
margin: 0;
}
.block-nice_menus h2.title .nice-menu-hide-title {
display: none;
}
.block-nice_menus h2.title .nice-menu-show-title {
display: block;
margin-bottom: 5px;
}

ul.nice-menu,
ul.nice-menu ul{
list-style: none;
padding: 0;
/* margin: 0;*/
border: 0;
/* border-top: 1px solid #ccc;*/
z-index: 5;
}

ul.nice-menu li {
border: 1px solid #ccc;
border-top: 0;
position: relative;
float: left;
background-color: #eee;
}

ul.nice-menu a {
padding: 0.3em 15px 0.3em 5px;
display: block;
}

ul.nice-menu ul{
position: absolute;
top: 1.8em;
left: -1px;
border: 0;
border-top: 1px solid #ccc;
margin-right: 0;
display: none;
}
ul.nice-menu li.over ul{
display: block;
}

ul.nice-menu ul li{
width: 12.5em;
display: block;
}

ul.nice-menu:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

/* Show submenus when over their parents */
ul.nice-menu li:hover ul,
ul.nice-menu li.menuparent li:hover ul,
ul.nice-menu li.menuparent li.menuparent li:hover ul,
ul.nice-menu li.over ul,
ul.nice-menu li.menuparent li.over ul,
ul.nice-menu li.menuparent li.menuparent li.over ul {
display: block;
}

/* Hide sub-menus initially */
ul.nice-menu li:hover ul ul,
ul.nice-menu li:hover ul ul ul,
ul.nice-menu li.over ul ul,
ul.nice-menu li.over ul ul ul {
display: none;
}

/* stuff for HORIZONTAL menus where submenus pop DOWN */

ul.nice-menu-down {
float: left;
border: 0;
}

ul.nice-menu-down li {
border-top: 1px solid #eee;
background: #ccc;
}

ul.nice-menu-down li li {
border-top: 0;
}

ul.nice-menu-down ul {
left: 0;
}

ul.nice-menu-down li ul li ul {
left: 12.5em;
top: -1px;
}

ul.nice-menu-down .menuparent a{
padding-right: 15px;
}

ul.nice-menu-down li.menuparent{
background: #eee url(arrow-down.png) right center no-repeat;
}

ul.nice-menu-down li.menuparent:hover,
ul.nice-menu-down li.over{
background: #ddd url(arrow-down.png) right center no-repeat;
}

ul.nice-menu-down li li.menuparent{
background: #eee url(arrow-right.png) right center no-repeat;
}

ul.nice-menu-down li li.menuparent:hover,
ul.nice-menu-down li li.over{
background: #ccc url(arrow-right.png) right center no-repeat;
}

ul.nice-menu-down ul li {
clear: both;
}

At least, it was close enough. I'm not using nicemenus anymore in 5.x, so I can't fiddle with it anymore, but this was my old css.

gavinrolph’s picture

ul.nice-menu li {
	position: relative;
	left: 15px;

that worked for me to centre it in the header.
Hope that helps. any ideas on how to centre the font in the menu though?
Gav

durum’s picture

Instead of setting your Nice Menu as a block, call your nice menu from your page.tpl.php (or your other.tpl.php) as explained in http://drupal.org/node/236418. Put it into a div as I did below:

<div id="your-menu-carrier">
  <?php
     $menu = theme('nice_menu', 1, 'your-menu-id', NULL, 'down');
     print $menu['content'];
  ?>
</div>

Add this to your templates css file:

#your-menu-carrier {
  float: left;
  position: relative;
  left: 50%;
}

Then in the default css file (or in the one that you've edited as stated in here http://drupal.org/node/185543) of Nice Menus find this css class and change it as I did:

ul.nice-menu-down {
  position: relative;
  left: -50%;
  /*float: left;
  border: 0;*/
}

Centers the menu in Firefox, Opera, and IE7.
Hth.

Edit: I missed that the topic was for 4.7, this is for 6.x and the differ for the 5.x is in where you call the menu (explained in http://drupal.org/node/186684). And for the 4.7 I have no idea if you can call the menu without using a block.

bunnyfly’s picture

Thank you so much! This is a perfect solution! I've been using pixel padding...doesn't work perfectly, but gets the job done. This works beautifully.

With Zen Theme I added to my themeName.css:

.block-nice_menus div div { float: left; position: relative; left: 50%; }
.block-nice_menus ul { position: relative; left: -50%; }

^_^

gearhead’s picture

That CSS works great in Zen theme as well.
Thanks!

Check it out @ http://www.musclecarsociety.com

gearhead’s picture

Darn IE!
The CSS works to center it but the way it is displayed in IE brakes the site. Of course it works fine in FireFox.

Back to left alignment!
Darn IE!

paulcretu’s picture

the creators of nice menus recommend styling by editing nice_menus_default.css (or creating a copy of it).

i can align one of my nice menus (in the footer) to the right by placing the following in the nice_menus_default.css :

DIV.content ul#nice-menu-2 {
float: right; }
(this works by aligning the surrounding div in garland theme)

or

DIV.content ul#nice-menu-2 {
float: right; }

Both work. But if I use instead margin-left: auto; margin-right: auto, to center the menu, this does not work.
I was horrified to read above tens of line of code for such a small task. It should work the way I tried above - with a single, simple line of code. Why does margin not work?

P.S. Drupal was about to be nice and (designer-/customizing-)friendly. Writinh 50 lines of code and editing 3 files for alighting a menu.... doesn't seem very...friendly.

Hey, I know, it's free, it's open source, I can't complain. But there MUST be an easier way. Float: right works. Please, can someone point me to a reason why margin auto wouldn't work?

rmmcclay’s picture

Thank you, bunnyfly. That's elegant.

damien_vancouver’s picture

Just a note to say that in Drupal 7 you can us this approach with:

/* Center nice menus - http://drupal.org/node/99174 */
.block-nice-menus div div { float: left; position: relative; left: 50%; }
.block-nice-menus ul { position: relative; left: -50%; }

But this method has problems. If it doesn't work for you (mine started working but then with more testing the menus were jumping around when I hovered over them), then you might need to use a javascript solution.

Fiable.biz’s picture

Well, it works, but an empty part overflows to the right, so I get an inelegant horizontal lift showing... nothing if used. If I put an "overflow: hidden;" on the navigation region, then the submenus are hidden too, so it's not a solution. Any idea to solve this cosmetic problem?

http://Fiable.biz Web site creation.

mingos’s picture

I used a JS approach. Here's what I did, step by step:

1. Create a new file in the theme directory.
I named this file "menu.js" and its contents are as follows:
function adjustPadding() {
  var w = 500 - (document.getElementById('nice-menu-1').offsetWidth / 2);
  document.getElementById('nice-menu-1').style.paddingLeft = w+"px";
}

The 'nice-menu-1' is the menu ID, and 500 is half the width of the div it's contained in (I have a 1000px wide wrapper). This is theme-specific stuff and will vary.

2. Add the file to the theme
It requires editing the file #themeName#.info. Just add the line:
scripts[] = menu.js
3. Make the script execute
Still in the theme directory, edit the file page.tpl.php. Find the body tag and change this:
<body>
into this:
<body onload="adjustPadding()">

It works perfectly with my custom theme. Confirmed working in:
- Firefox 3.6.3
- Chrome 4.1
- Opera 10.52
- Safari 4.0.5
- IE 8
- IE 7

I certainly hope this does NOT work in IE6, so that it gets another reason to finally go to hell :P.

solar3000’s picture

Here's my take on this:

The only changes I made are:

nice_menus_CUSTOM.css:

Search for:
ul.nice-menu,
ul.nice-menu ul { ....
...
}

Inseted:
position: relative;
left: 50%;
This puts the starting point (left) of menu at 50%

Search for:
ul.nice-menu li {
...
}

Inserted:
position: relative;
left: -225px;
I've measured the width of my menu in pixels and divided it by 2 like this:
500 px wide / 2 = 225
This one moves the menu half way left so that it is now fully centered.

So, here:
First change puts menu here

|--------------------------------------------------------------|
|                                   [ my very big menu here ]  |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|--------------------------------------------------------------|


Second change puts menu here

|--------------------------------------------------------------|
|                    [ my very big menu here ]                 |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|                                                              |
|--------------------------------------------------------------|
mingos’s picture

@solar3000: this is risky. If I don't have the same font as you do, the results will differ. They can even differ across browsers on the same machine (not like to be noticeable, but still).

abhinya’s picture

kinda primitive.
Place the navigation section into a table like this:

<table class="centre_my_table">
<tr><td><div class="position_nav_bar"><?php print $navigation; ?></div></td></tr>
</table>

The CSS "position_nav_bar" i use for some other internal customization.
The css for centre_my_table:

.centre_my_table	{
	margin-left:auto;
	margin-right:auto;
}

There is some margin and padding correction that needs to be done. Once done NM in the centre works Pronto.

You can check the site : http://kgsplus.com/MP/
site under development.

Anandyrh’s picture

Got it working!

give your [.navigation ul] or [parent div] a width and use margin:0 auto;

But now am trying to modify this to wide screen. Nice menu to expand automatically based on users screen size... any of you have any idea on this.. please share it here.

Thanks in advance,
AnAnD

jshimota01’s picture

Client asked for centering of the horizontal menu on a fixed width page. Previous designer (not a developer per se) used Nice Menu's to accomplish the horizontal menu... with support for Superfish turned on (the javascript switch etc).

I tested using css injector:
/* The wrapping the nice menu ul */
#block-nice-menus-1 div.content {
position: relative;
float: left;
left: 50%;
}
/* The nice menu ul */
#block-nice-menus-1 #nice-menu-1 {
position: relative;
float: left;
left: -50%;
}

and viola. centered. ** Except ** I got the horizontal bar problem on the bottom of my page. I dug all through the codes and not being css capable... couldn't figure out squat. Firebug did expose some of the problem, but not really much help. I tried adding widths ala:
#block-nice_menus-1 {
margin:auto;
width: 985px;
}

#main-menu {
margin: auto;
width: 1200px;
}

#main-menu-inner {
margin: auto;
width: 1010px;
}
and still had the trouble. Then I discovered these entries in a superfish dialog - #28 and #29 - and modified it by adding these entries to the bottom of my customized nice menus css file:

#block-nice-menus-1 { text-align: center; }
ul#nice-menu-1 { display: inline-block; float: none; }
.region-featured {padding: 0;margin-bottom: -5px;} /* my region was called featured - you undoubtedly will use a different region name on this line if you cut/paste */

poof. FINALLY a fix after 2 days. Tested on chrome (v unknown), FF 37 and Ie 11, all good. Someday when I have 6 months to kill I'll learn css....

"I'd rather program the calculations of the moons' trajectory after contact with a meteor then dink with CSS."