如何中心CSS下拉菜单 [英] How To Center A CSS Drop Down Menu
本文介绍了如何中心CSS下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一些帮助。我有一个CSS下拉菜单,但我希望标题中心,所以在所有的屏幕尺寸,它将在中间,因为它暂时停留在左边。
以下是一些HTML代码:
< div id ='cssmenu'>
< ul>
< li>< a href ='events.html'>< span> Events< / span>< / a>< / li&
< / ul>
解决方案
将此CSS替换为#cssmenu> ul> li:
#cssmenu> ul> li {
display:inline-block;
margin-left:15px; / *这是当下拉框出现时* /
position:relative;
}
并将其添加到您的css代码:
#cssmenu> ul {
text-align:center;
}
这里是: http://jsfiddle.net/y4vDC/10/
I'm in need of some help. I have a CSS dropdown menu but i want the titles to be centered so on all screen sizes it would be in the middle, as at the moment its stuck to the left.
Any help would be greatly appreciated.
Here is a bit of the HTML code:
<div id='cssmenu'>
<ul>
<li><a href='events.html'><span>Events</span></a></li>
</ul>
解决方案
replace this css with what you have for #cssmenu > ul > li:
#cssmenu > ul > li {
display:inline-block;
margin-left: 15px; /* This is when the drop down box appears */
position: relative;
}
and add this to your css codes:
#cssmenu > ul {
text-align:center;
}
here it is: http://jsfiddle.net/y4vDC/10/
这篇关于如何中心CSS下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文