简体   繁体   English

如何使表格单元的行为类似于UL LI?

[英]How can I make table cells behave like UL LIs?

I have a page of generated HTML which I cannot edit. 我有一个无法编辑的生成HTML页面。 The page has a table which contains two rows and each row has 4 cells each. 该页面有一个表,该表包含两行,每行各有4个单元格。 I want to force the cells to behave like unordered list items so that they display in a vertical list. 我想强制单元格表现得像无序列表项,以便它们显示在垂直列表中。 I know this is horrible hacking, but it really is my only choice at the moment. 我知道这是骇人听闻的骇客,但目前确实是我唯一的选择。 Is there a way to get table cells to display vertically rather than horizontally? 有没有办法使表格单元格垂直显示而不是水平显示?

You have to change display property for cells. 您必须更改单元格的display属性。

Assume the class of your table is mytable, CSS code would be: 假设表的类是mytable,则CSS代码为:

.mytable td {
    display: block;
}

Check out this fiddle: http://jsfiddle.net/8Loy6x24/1/ 看看这个小提琴: http : //jsfiddle.net/8Loy6x24/1/

I wouldn't recommend this hack, though. 不过,我不推荐这种破解。

Try like this.. 像这样尝试

td {
    display: block;
}

DEMO DEMO

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

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