3

私はレスポンシブテーブルのこの例に従っていました: http://dbushell.com/demos/tables/rt_05-01-12.html

しかし、インラインブロックとして表示されるテーブル行の間に奇妙なスペースがあります。デモは次のとおりです: http://codepen.io/anon/pen/Fksjw

マージンをゼロにしようとしましたが、このスペースを取り除くことはできません。

4

3 に答える 3

6

What you see is the default behaviour of inline (inline-block) elements. One possible solution is to set font-size and line-height to 0 to make white spaces invisible. Then you just reset them back to some values:

tbody {
    ...
    line-height: 0;
    font-size: 0;
}
tbody td {
    ...
    line-height: 20px;
    font-size: 14px;
}

http://jsfiddle.net/W2ACD/1/

Another solution would be manually remove all the line breaks and spaces between tr.

于 2013-04-22T11:02:03.637 に答える
1

これを css に追加します。

table {
  border-collapse: collapse;
}

tbody tr {
   display: table-row;
}

tbody td {
   display: table-cell;
}
于 2013-04-22T10:52:43.547 に答える
0

Inline-block 要素は、常に 3 ピクセルの余分なマージンを提供します。水平方向の辺ごとに 3 ピクセルを減算して解決できます。

tbody tr {
   display: inline-block;
   margin: 0 -3px;
   vertical-align: middle;
}
于 2013-04-22T11:57:42.747 に答える