简体   繁体   English

li标签的垂直和水平编号

[英]vertical and horizontal numbering of li tags

Im sorry I wasn't sure what to call the title. 对不起,我不确定该怎么称呼。

Im using joomla and have a menu creating an ul tag and many li's. 我正在使用joomla,并具有创建ul标签和许多li的菜单。 within each of the li tags are there a link to a page. 每个li标签内都有指向页面的链接。 i have chosen to give my li tags numbers. 我选择给我的li标签号码。

right now the order is like this: 现在的顺序是这样的:

在此处输入图片说明

How is it possible using CSS/html or any other solution? 如何使用CSS / html或任何其他解决方案?

If you're not too concerned about backwards browser compatability you can use CSS columns: 如果您不太担心浏览器的向后兼容性,则可以使用CSS列:

ul {
    column-count: 3;
    column-gap: 5px;
}

ul li {
    display:block;
}

This should give you roughly what you want, however it won't work in IE9 or older. 这应该可以大致满足您的要求,但是在IE9或更旧的版本中将无法使用。 You should have full support in Chrome, Firefox and Safari by now though. 现在,您应该已经在Chrome,Firefox和Safari中获得了全面的支持。

Reference here: http://www.w3schools.com/css/css3_multiple_columns.asp 此处参考: http : //www.w3schools.com/css/css3_multiple_columns.asp

Use coloumns css rule 使用coloumns CSS规则

HTML HTML

 <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
    </ul>

css: CSS:

ul {
    -webkit-columns: 100px 3; /* Chrome, Safari, Opera */
    -moz-columns: 100px 3; /* Firefox */
    columns: 100px 3;
}

note: works with ie12+ 注意:与ie12 +一起使用

Set CSS columns property on ul 在ul上设置CSS 属性

 li{list-style-type: decimal-leading-zero;} ul { -webkit-column-count: 3; -moz-column-count: 3; column-count: 3; -webkit-column-width: 150px; -moz-column-width: 150px; column-width: 150px; /* or this for short code -webkit-columns: 150px 3; -moz-columns: 150px 3; columns: 150px 3; */ } 
 <ul> <li>item1</li> <li>item2</li> <li>item3</li> <li>item4</li> <li>item5</li> <li>item6</li> <li>item7</li> <li>item8</li> <li>item9</li> </ul> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM