Separators between elements without hacks

前端 未结 6 919
猫巷女王i
猫巷女王i 2020-12-14 08:18

One thing I often want to do when laying out a website is to have some elements next to each other, with separators between them. For instance, if I have 3 elements, I\'d wa

6条回答
  •  无人及你
    2020-12-14 09:11

    Well for a start, you can simplify it to this:

    things stuff items
    span {
        border-right: solid black 1px;
    }
    span.end {
        border-right: none;
    }
    

    If you're willing to drop some support in older browsers, you can reduce that to this, using the :last-child pseudo-class:

    things stuff items
    span {
        border-right: solid black 1px;
    }
    span:last-child {
        border-right: none;
    }
    

提交回复
热议问题