如何将列表居中? [英] How do I center a list?
本文介绍了如何将列表居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个无序列表,我想在页面中间.
I have an unordered list and I want to have it in the middle of the page.
通过这种方式,我的意思是左侧项目符号应与文本最长的列表项的中心垂直对齐,但应在页面的中心对齐?
By that, I mean that the left side bullets should be vertically aligned with the center of the list item with the longest text, but in the center of the page?
- 第1项很无聊
- 项目2确实是一个很长的项目,哦,是的,它是< ===中间字符应该在页面中心
- 第3项几乎与第1项一样无聊
而不是
* item 1 is boring
* item 2 is a very long item indeed, oh yes it is
* item 3 is almost as boring as item 1
推荐答案
以下是您的答案,该列表以可变宽度为中心: jsfiddle .它是纯CSS,不会添加任何额外的标签.
Here is an answer for you which centers your list with variable width: jsfiddle. It's pure css and doesn't add any extra tags.
该方法最早是在此处发布的,并且几乎可以在所有浏览器中使用.
The method was first published here, and should work in just about all browsers.
这篇关于如何将列表居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文