How to prevent column break within an element?

后端 未结 18 2311
刺人心
刺人心 2020-11-22 16:09

Consider the following HTML:

  • Number one
  • Number two
  • &
18条回答
  •  无人及你
    2020-11-22 16:27

    I made an update of the actual answer.

    This seems to be working on firefox and chrome: http://jsfiddle.net/gatsbimantico/QJeB7/1/embedded/result/

    .x{
    columns: 5em;
    -webkit-columns: 5em; /* Safari and Chrome */
    -moz-columns: 5em; /* Firefox */
    }
    .x li{
        float:left;
        break-inside: avoid-column;
        -webkit-column-break-inside: avoid;  /* Safari and Chrome */
    }
    

    Note: The float property seems to be the one making the block behaviour.

提交回复
热议问题