2013-10-13 136 views
0

我正在发民导航菜单CSS调整宽度取决于元素

enter image description here

如果你看到的图像,还有一些空间在正确的, 我怎么能自动调整空间也离开了。

的任何元素的存在不fixed..They可以2,3,4或东西

[目前有4]

+0

你想让你的导航栏占据整个容器吗? – Matt

+0

是 但没有在导航栏的变化子菜单中,可以是2,3 4,6,10 目前他们4 –

回答

1

实现这一目标将有最好的方法你水平导航栏的行为如同ul上的display: table;并在lidisplay: table-cell

如果您发布了一些代码,我将能够给您一些更好的说明;但这里有一个例子:

nav { 
     width: 500px; /* This would be set to the width of the existing container */ 
    } 

    nav ul { 
     list-style: none; 
     margin:0; 
     padding:0; 
     display: table; 
     width: 100%; 
    } 

    nav li { 
     text-align: center; 
     display: table-cell; 
    } 
    nav a { 
     display: block; 
     text-align: center; 
    } 
+0

这didnt工作 检查http://demo.techento.com/ –

+0

你'.menu-item'有一个'width'&'float:left'属性。这就是为什么它不起作用。删除这两个,它会工作。 – Matt

+1

非常感谢你,它的工作 –

相关问题