chrome不尊重显示属性

dav*_*k01 5 html css google-chrome

有什么特别的原因可以解释为什么chrome "display:inline"在使用时不尊重"<table>"并且是否有已知的解决方法?在Firefox中一切正常,但由于某种原因,当我输入时,chrome拒绝做正确的事情

<table style="display:inline;">
    table stuff
</table>
Run Code Online (Sandbox Code Playgroud)

firefox alignment:firefox alignment http://dkarapet.userworld.com/cart_noDB/firefox_alignment.png

chrome alignment:chrome alignment http://dkarapet.userworld.com/cart_noDB/chrome_alignment.png

两个版本都使用相同的html源,将display属性设置为inline.单独的表不包含在任何其他div中,它们都包含在一个大div中.这是html相关部分的贴图.

Álv*_*lez 7

试试inline-block.


Tim*_*Tim 1

要提取您想要的内容,您只需将其添加到每个 td 中:

<td valign="top">
Run Code Online (Sandbox Code Playgroud)

这将迫使所有内容都位于每个单元格的顶部,并强制内容按您希望的方式内联显示。这里不需要CSS。

它应该这样编码:

<table>
 <tr>
  <td valign="top">item 1 info</td>
  <td valign="top">item 2 info</td>
  <td valign="top">item 3 info</td>
 </tr>
 <tr>
  <td valign="top">item 4 info</td>
  <td valign="top">item 5 info</td>
  <td valign="top">item 6 info</td>
 </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

编辑:或者如果(由于某种原因)您没有使用 TR 和 TD,您可以尝试以下操作:

<table style="vertical-align:top;">
    table stuff
</table>
Run Code Online (Sandbox Code Playgroud)