CSS3 multi-column list

前端 未结 1 1928
清酒与你
清酒与你 2020-12-25 14:56

I\'ve been using CSS3 multi-column for a few Wordpress sites now and one thing that I find excepteble but still something I want to know how to fix is that if I put a list(w

相关标签:
1条回答
  • 2020-12-25 15:29

    Making your parent <li> display: inline-block; seems to "fix" this:

    Here is a demo http://jsfiddle.net/DczVL/1/

    ul {
        list-style: none;
        margin:0;
        padding:0;
    }
    ul > li {
        display: inline-block;
        width: 100%;
    }
    ul > li > ul >li {
        color: red;
    }
    div {
        -webkit-column-count:3;
        -moz-column-count:3;
        -ms-column-count:3;
        -o-column-count:3;
        column-count:3;
        -webkit-column-gap:15px;
        -moz-column-gap:15px;
        -ms-column-gap:15px;
        -o-column-gap:15px;
        column-gap:15px;
        columns:3;
    }
    <div>
        <ul>
            <li>List-item
                <ul>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                </ul>
            </li>
            <li>List-item
                <ul>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                </ul>
            </li>
             <li>List-item
                <ul>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                    <li>Sub-list-item</li>
                </ul>
            </li>
        </ul>
    </div>

    0 讨论(0)
提交回复
热议问题