CSS styling for horizontal list with bullet only between elements

后端 未结 11 2365
刺人心
刺人心 2020-12-09 07:23

I\'m not sure how to build a horizontal list that looks like this:

\"Centered

11条回答
  •  一个人的身影
    2020-12-09 07:53

    For almost all browsers, you can use the CSS3 selector last-child instead of JavaScript:

    ul li { display: inline; white-space: pre; }
    ul li:after { content: "  \00b7  "; }
    ul li:last-child:after { content: ""; }
    

    The white-space: pre stops wrapping within list items (because usually you want it to wrap between list items), and is a hack that allows you to increase the space between list items by adding spaces on the second line.

    u00b7 ⋅ (MIDDLE DOT) is the standard unicode character for interpuncts, but you could also use u2022 • (BULLET),   u2b24 ⬤ (BLACK LARGE CIRCLE),   U+2043 ⁃ (HYPHEN BULLET), or any other unicode character you choose.

    Note that some characters may not be supported on all systems.

提交回复
热议问题