[英]CSS menu isn't centered
I have built this menu: 我建立了这个菜单:
JSBIN EDIT ;
JSBIN编辑 ;
JSBIN DEMO
JSBIN演示
As you see, the menu isn't centered at the middle of the bar, he's centered up. 如您所见,菜单不在居中位置,而是居中。 However, I want to make it go lower, exactly at the middle.
但是,我想降低它,恰好在中间。
So, I had an idea to do margin-top: 26px
because the bar's height is 53 pixels, but it doesn't change anything. 因此,我有一个想法可以做
margin-top: 26px
因为条形的高度为53像素,但它没有任何改变。 I also did margin: 0 auto
and text-align:center
. 我也做了
margin: 0 auto
和text-align:center
。
I read this STACKOVERFLOW and realized that it is related in float, but I don't want to float it - I want to make it go down.
我阅读了此STACKOVERFLOW,并意识到它与float相关,但我不想使其浮动-我想使其下降。
Thank you! 谢谢!
You need to give the line height by using
line-height
.
您需要使用
Okay, updated , the line-height
来指定
line-height
。
line-height
trick doesn't work!!! 好的, 已更新 ,
line-height
不起作用!!! And also, giving this to the <a>
tag does the trick: 而且,将其赋予
<a>
标记也可以达到目的:
width: auto;
display: inline-block;
尝试将链接的line-height
设置为条形的高度,在此示例中为53像素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.