I have some difficulties trying to center my dropdown navigation.
Below I posted an image of the current design and some CSS.
As you can see, the dropdown doesn't fit on the page.
.structure-mainnavigation ul li ul {
width:500px;
}
.structure-mainnavigation ul li ul li {
width:25%;
float:left;
text-align: center;
}
Any help is appreciated.
After messing around for hours and hours i solved my own problem by adding the following code:
li:hover ul { left:auto; right:0; }
you can try:
position: absolute;
margin:0 auto;
when you say centering you mean to put drop down on center of the page or center of menu item?
Related
I am using the archi wordpress theme which is a great theme.
I am looking how to make the dropdown menu width wider so my text is on 1 line rather then 2 lines.
My website: http://cobbys.gentwijzer.be/fabrieksverkoop/
For example menu item: Stoffen, dropdown is ok except for "brandvertragende stoffen" . How do I increase the width of the dropdown so it will be on 1 line.
Thank you
I would change from:
#mainmenu li ul {
width: 200px;
}
#mainmenu li li a {
width: 200px;
}
to
#mainmenu li ul {
width: auto;
}
#mainmenu li li a {
width: auto;
white-space: nowrap;
}
Using width: auto will allow the ul of the dropdown to grow as needed and you won't be stuck specifying a universal width for all dropdowns or manually setting a specific width for each dropdown.
white-space: nowrap; prevents the text from wrapping to a new line when there is not sufficient space to do so.
Set the width of #mainmenu li ul to what ever you want(for example 300px) and on #mainmenu li li a use width:auto
I am trying to get some menus to look good, but I seem to have two options that do half of what I want. What can I do that will give me both of the behaviors I want?
The problem is with the offset in my menu. When I set the submenu to relative. Everything expands as it shouldn't. When a submenu is moused over it expands in place instead of off to the right as I would like it to. The jsfiddle below shows this behavior:
http://jsfiddle.net/7a4dzxt2/
When I use absolute, all the sub menus are stuck to the left. They exapnd exactly as I would like, but each menu is all the way on the left of the screen and not directly below the main menu item. The jsfiddle below shows this:
http://jsfiddle.net/w8ztr9eb/
The code that is being changed is:
#navbar ul li ul {
display:none;
position:absolute;
left: 30px;
background-color:transparent;
padding:10px;
opacity:0.95;
}
To:
#navbar ul li ul {
display:none;
position:relative;
left: 30px;
background-color:transparent;
padding:10px;
opacity:0.95;
}
How can I keep the menus from expanding like in the second jsfiddle, but keep the menu from being stuck to the left side of the page?
If you set the containing li elements to position: relative then your absolutely positioned ul elements will be positioned in relation to their parent:
#navbar ul li {
/* ... */
position: relative;
}
http://jsfiddle.net/w8ztr9eb/3/
It's a start. When you use absolute, it positions based on the nearest positioned parent. So, try:
#navbar ul li {
position: relative;
}
#navbar ul li ul {
position:absolute;
left: 0px;
padding:1px;
}
http://jsfiddle.net/w8ztr9eb/2/
I'm having a little trouble centering the menu items in my Wordpress theme. You can see the site here: http://tinyurl.com/k2aq3sh
I tried margin:auto but no dice. Here is the current CSS:
#primary-menu-container {
margin-bottom:-27px;
margin-top:-10px;
text-align: left;
float: left;
max-width:1020px;
}
Any help would be greatly appreciated!
If you mean to center the whole menu in the nav bar, do it like this:
#primary-menu {
list-style: none;
display: flex;
justify-content: center;
}
One way of doing this would be to remove the floating of the #primary-menu-container div and the list items. Instead add display:inline-block to the list items and from there you can add text-align:center to the ul element
#primary-menu-container {
...
float:none
}
#primary-menu{
...
text-align:center;
}
#primary-menu li, .default-menu li {
...
float:none;
display:inline-block;
}
need some help in this.
On hover I want the drop down ul to be align right and not left which is currently there
Please here
Here is my fiddle
http://jsfiddle.net/cancerian73/kqZMf/4/
This is my css
ul, li, a {
margin: 0;
padding: 0;
}
Hi I want to add a down arrow to the first flyout.
http://www.spheretekk.com/ncf/ss.jpg
.nav > li.hover > ul {
left: auto;
right:0;
}
Would this be what you are trying to do on first sub-level ?
http://jsfiddle.net/kqZMf/3/
You could float it right or use position: absolute;. Here's position: absolute example
DEMO http://jsfiddle.net/kevinPHPkevin/kqZMf/1/
.main-nav {
position: absolute;
right:10px;
}
Add this to your css:
.main-nav {
float: right;
}
Fiddle
Here is the link to the fiddle : http://jsfiddle.net/UL2LB/1/
As you can see, I only have specified z-indexes on the hidden sub-list and the nav element, both of which have explicit positioning. So my question is, why the hell is my sub-menu still showing on top of the <nav>?
Thank you in advance for any answer.
Give your ul a pixel width and add position:relative to it the li.
nav.global ul li ul {
width:180px;
...
}
nav.global > ul > li {
display: inline-block;
margin-left: 2%;
position: relative;
}