Add a pipe separator after items in an unordered list unless that item is the last on a line

前端 未结 10 1046
逝去的感伤
逝去的感伤 2020-11-29 18:54

Is it possible to style this html ...

  • Dogs
  • Cats
  • Lions
  • Tig
10条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 19:13

    Slightly modified SCSS version which gives you control of the pipe | size and will eliminate padding from first and last list items while respects borders.

    
    $pipe-list-height: 20px;
    $pipe-list-padding: 15px;
    
    .pipe-list {
        position: relative;
        overflow: hidden;
        height: $pipe-list-height;
    
        > ul {
            display: flex;
            flex-direction: row;
    
            > li {
                position: relative;
                padding: 0 $pipe-list-padding;
    
                &:after {
                    content: " ";
                    position: absolute;
                    border-right: 1px solid gray;
                    top: 10%;
                    right: 0;
                    height: 75%;
                    margin-top: auto;
                    margin-bottom: auto;
                }
    
                &:first-child {
                    padding-left: 0;
                }
    
                &:last-child {
                    padding-right: 0;
    
                    &:after {
                        border-right: none;
                    }
                }
            }
        }
    }
    
    • Link
    • Link
    • Link

提交回复
热议问题