I often want to horizontally center an horizontal menu (an unordered list with the li
elements floated) without specifyling a fixed width, so that the menu remains centered in all resolutions.
我经常想要水平居中一个水平菜单(一个无序的列表,其中li元素浮动),而没有指定固定的宽度,因此菜单保持在所有分辨率的中心。
To my knowledge there's no way to achieve that, but perhaps there is some little know trick to achieve it?
据我所知,没有办法实现这一目标,但也许有一些小知识可以实现它?
1 个解决方案
#1
0
Won't this do the trick?
这不是诀窍吗?
ul{
list-style:none;
width:100%;
text-align:center;
}
li{
display:inline-block;
}
#1
0
Won't this do the trick?
这不是诀窍吗?
ul{
list-style:none;
width:100%;
text-align:center;
}
li{
display:inline-block;
}