Targeting nth column (made by column-count)

前端 未结 4 806
孤城傲影
孤城傲影 2021-01-18 05:32

Let\'s say I have this

  • test
  • test
  • test
  • test
4条回答
  •  不要未来只要你来
    2021-01-18 06:13

    You can use column-gap to do what you want, though since one cannot use calc(100% - liWidth * colCount) as a value for column-count, you'd have to use some javascript right now

    function calcGap() {
        var gap = window.innerWidth - (columnCount * listWidth) + "px";
        ul.style.webkitColumnGap = gap;
        ul.style.columnGap = gap;
    }
    calcGap(); // Fire on load
    window.onresize = calcGap; // Fire on window resize
    

    Demo

    Using this method you can have whatever text-align you want as well as not messing up other alignment properties

提交回复
热议问题