Centering Bullets On A Centered List

前端 未结 4 1115
滥情空心
滥情空心 2020-12-30 23:28

Example - http://jstn.info/html.html - link rot, example no longer available.

Notice the text is centered, but the bullet points themselves are not.

4条回答
  •  星月不相逢
    2020-12-31 00:14

    The problem is that the bullets are controlled by the ul rather than the individual lis. I don't know a clean way of doing this off the top of my head; as a quick hack, try

    ul { list-style-type: none; text-align: center; }
    li::before { content: "\2022 " }
    /* 0x2022 is unicode for a bullet */
    

    Edit: as the user above me points out, you should be centering in the stylesheet rather than with align.

    To clarify, what we've actually done here is hidden the automatically-generated bullets (by setting list-style-type to `none) and created "pseudo-bullets" in front of each li.

提交回复
热议问题