Html/css 列表项 区分列表首尾
列表项,有时需要判断列表首尾,来筛选设置样式 如上图,三个项有间隔,怎么保证设置了列表项之间的距离后,整体还水平居中显示呢? .item:not(:first-child) { margin-left: 20px; } 1 <! DOCTYPE html > 2 < html > 3 < head > 4 < meta charset ="UTF-8" > 5 < title > Document </ title > 6 < style type ="text/css" > 7 .container { 8 width : 600px ; 9 height : 300px ; 10 background : rgba(4,0,255,0.50) ; 11 } 12 .list-parentOuter { 13 float : left ; 14 margin-left : 50% ; 15 } 16 .list-parentInner { 17 position : relative ; 18 right : 50% ; 19 display : flex ; 20 flex-direction : row ; 21 justify-items : center ; 22 margin-top : 50px ; 23 } 24 .item { 25 height :