将级联列表样式设置为表
只是问是否有一种方法可以设计这样的级联列表:
<ol>
<li>
<ol>
<li>col 1 row 1</li>
<li>column 2 row 1</li>
</ol>
</li>
<li>
<ol>
<li>column 1 row 2</li>
<li>col 2 row 2</li>
</ol>
</li>
</ol>
进入这样的表
------------------------------------------------------
|col 1 row 1 |column 2 row 1 |
|column 1 row 2 |col 2 row 2 |
------------------------------------------------------
,其中每行都是具有相同宽度的水平列表
我一直在尝试实现这一点,但只能达到尽可能接近的
------------------------------------------------------
|col 1 row 1 |column 2 row 1 |
|column 1 row 2 |col 2 row 2 |
------------------------------------------------------
程度不要使每个单元格的宽度相同。 这是我的 css
ol.question_list {
list-style: decimal;
width: 100%;
}
ol.question_list li {
clear: both;
width: 100%;
}
ul.choice_list {
list-style: none;
padding: 0;
margin: 0 auto;
width: 100%;
}
ul.choice_list li {
display: inline;
list-style-type: none;
}
,这是我的示例 html
<ol class="question_list">
<li>
<ul class="choice_list">
<li>abc</li>
<li>defghi</li>
</ul>
</li>
<li>
<ul class="choice_list">
<li>abc12345</li>
<li>defghi12345</li>
</ul>
</li>
</ol>
任何想法都将受到高度赞赏。
我已经找到了解决方案,但在此之前我要感谢此线程中的回复。 解决方案是这样的:
ol.row_list {
list-style: decimal;
padding: 0;
margin: 0 auto;
width: 100%;
}
ol.row_list li:after {
content: " ";
display: block;
line-height: 1px;
font-size: 1px;
clear: both;
}
ul.col_list {
list-style: none;
padding: 0;
margin: 0 auto;
width: 100%;
}
ul.col_list li {
display: block;
float: left;
width: 8%;
margin: 0;
padding: 0;
}
div {
display: table;
}
html 看起来像这样
<div>
<ol class="row_list">
<li>
<ul class="col_list">
<li>abc
</li>
<li>12345
</li>
</ul>
</li>
<li>
<ul class="col_list">
<li>abc12345
</li>
<li>1234567890
</li>
</ul>
</li>
</ol>
</div>
Just asking if there is a way to style a cascade list like this:
<ol>
<li>
<ol>
<li>col 1 row 1</li>
<li>column 2 row 1</li>
</ol>
</li>
<li>
<ol>
<li>column 1 row 2</li>
<li>col 2 row 2</li>
</ol>
</li>
</ol>
into a table like this
------------------------------------------------------
|col 1 row 1 |column 2 row 1 |
|column 1 row 2 |col 2 row 2 |
------------------------------------------------------
where each row is a horizontal list with the same width
I've been experimenting to achieve this, but can only get as close as this
------------------------------------------------------
|col 1 row 1 |column 2 row 1 |
|column 1 row 2 |col 2 row 2 |
------------------------------------------------------
I can't make each cell the same width.
Here is my css
ol.question_list {
list-style: decimal;
width: 100%;
}
ol.question_list li {
clear: both;
width: 100%;
}
ul.choice_list {
list-style: none;
padding: 0;
margin: 0 auto;
width: 100%;
}
ul.choice_list li {
display: inline;
list-style-type: none;
}
and here is my sample html
<ol class="question_list">
<li>
<ul class="choice_list">
<li>abc</li>
<li>defghi</li>
</ul>
</li>
<li>
<ul class="choice_list">
<li>abc12345</li>
<li>defghi12345</li>
</ul>
</li>
</ol>
Any ideas will be highly appreciated.
I've found the solution, but before I would like to thank for the response in this thread.
The solution is like this:
ol.row_list {
list-style: decimal;
padding: 0;
margin: 0 auto;
width: 100%;
}
ol.row_list li:after {
content: " ";
display: block;
line-height: 1px;
font-size: 1px;
clear: both;
}
ul.col_list {
list-style: none;
padding: 0;
margin: 0 auto;
width: 100%;
}
ul.col_list li {
display: block;
float: left;
width: 8%;
margin: 0;
padding: 0;
}
div {
display: table;
}
and the html looks like this
<div>
<ol class="row_list">
<li>
<ul class="col_list">
<li>abc
</li>
<li>12345
</li>
</ul>
</li>
<li>
<ul class="col_list">
<li>abc12345
</li>
<li>1234567890
</li>
</ul>
</li>
</ol>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你试试这个吗?
you try this?
CSS
HTML
CSS
HTML