完全html与css中不同项目的最大宽度相同

时间:2017-03-30 06:40:54

标签: html css

是否可以编写一个css类,其中宽度动态地是最长项目的宽度?

我知道如何在jquery中执行它(迭代)但我需要它在css / css3中

1 个答案:

答案 0 :(得分:0)

CSS代码动态设置宽度

所有行的宽度将设置为最长行的宽度。



ul{
    margin: 0;
    padding: 5px;
    list-style: none;
    width:50%;
    background-color: #eee;
}

ul::after {
    clear: both;
    content: "";
    display: block;
}

li {
    background: grey none repeat scroll 0 0;
    display: block;
    float: left;
    margin: 5px;
    width: calc(50% - 10px);
}

<ul>
    <li>row 1</li>
    <li>row 2</li>
    <li>This is the widest row 3</li>
    <li>row 4</li>
</ul>
&#13;
&#13;
&#13;