[英]Centering a span vertically and horizontally within a list item
I'm having problems centering a span horizontally and vertically in a list item. 我在列表项的水平和垂直居中居中时遇到问题。 It's just sticking in the top left corner.
它只是停留在左上角。 Here's my markup:
这是我的标记:
<ul id="folders">
<li class="add"><span></span></li>
</ul>
I've set the span to vertical-align to middle, and set the list item text-align to center, but that doesn't help. 我已经将跨度设置为“垂直对齐”到中间,并将列表项“文本对齐”设置为居中,但这无济于事。
I've created a jsfiddle here: http://jsfiddle.net/Qfars/ 我在这里创建了一个jsfiddle: http : //jsfiddle.net/Qfars/
Anyone know how I can center this? 有人知道我该如何定心?
To align your span on the center add the following to the css: 要在中心对齐您的跨度,请在css中添加以下内容:
margin-left:auto;
margin-right:auto;
vertical-align doesn't work as you expect it to. 垂直对齐无法正常工作。 It will work this way only in a table.
它将仅在表中以这种方式工作。
Here 's more information about vertical-align, and how you can solve your vertical-align problem. 这里是有关垂直对齐以及如何解决垂直对齐问题的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.