显示:阻止在Chrome或Safari中无法使用 [英] Display:Block not working in Chrome or Safari
问题描述
我有一个简单的需要垂直显示表格行的单元格。
下面的例子按照预期在FF中渲染,每个行单元格都在下面,但是在下面的例子中,在Chrome中,似乎忽略显示:完全阻止。
这是什么问题 - 或者有更好的方法。
这是im使用@media在CSS中渲染表为一个小屏幕不同)
更多的视觉效果:
正常表可能是
DATA1 | DATA2 | DATA3
但显示为:block,应为
DATA1
DATA2
DATA3
很感谢
< html&
< head>
< style>
table,
thead,
tr,
td
{
display:block;
}
table,tr
{
border:1px dotted red;
}
td
{
border:1px
}
thead
{
display:none;
}
< / style>
< / head>
< body>
< table>
< thead>
< tr>
< td>标题1< / td>
< td>标题2< / td>
< td>标题3< / td>
< / tr>
< / thead>
< tbody>
< tr>
< td>数据1< / td>
< td>数据2< / td>
< td>数据3< / td>
< / tr>
< tr>
< td>数据1< / td>
< td>数据2< / td>
< td>数据3< / td>
< / tr>
< tr>
< td>数据1< / td>
< td>数据2< / td>
< td>数据3< / td>
< / tr>
< / tbody>
< / table>
< / body>
< / html>
EDIT 2: / p>
我想我已经解决了你的问题。 Webkit覆盖 display:block;
并且在td中计算为 display:table-cell;
<!DOCTYPE>
已为您的html声明。
为了解决这个问题,我建议您在之前设置
<!DOCTYPE html>
jsfiddle的工作原因是因为网站有一个< ;!DOCTYPE>
已声明。
尝试这个,让我知道如果它解决了您的问题。如果没有,我会尝试找到另一个答案。
I have a simple need to display the cells of a table row vertically. This works just fine in FF, but not in Chrome or Safari on the Ipad.
The example below renders as expected in FF, with each row cell under each other, but in Chrome, it seems to ignore the display:block altogether.
What is the issue - or is there a better way to do this.
(The reason for wanting this is that im using @media in the CSS to render the table differently for a small screen)
for a more visual example:
A normal table might be
DATA1 | DATA2 | DATA3
but with display:block, it should be
DATA1
DATA2
DATA3
Many Thanks
<html>
<head>
<style>
table,
thead,
tr,
td
{
display:block;
}
table,tr
{
border : 1px dotted red;
}
td
{
border:1px dashed blue;
}
thead
{
display:none;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<td>Heading 1</td>
<td>Heading 2</td>
<td>Heading 3</td>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</tbody>
</table>
</body>
</html>
EDIT 2:
I think I have worked out your problem. Webkit overrides display: block;
and computes it to be display: table-cell;
in a td when there is no <!DOCTYPE>
declared for your html.
To fix this I recommend you set <!DOCTYPE html>
before <html>
at the top of your html.
The reason the jsfiddle will work is because the site has a <!DOCTYPE>
already declared.
Try this and let me know if it fixes your problem. If not I'll try find another answer.
这篇关于显示:阻止在Chrome或Safari中无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!