我有一个旋转标题的表,在Chrome中看起来像预期的那样,但在Firefox中不是。
Chrome v108(垂直底部,水平中间)
Firefox v107(垂直居中,水平向右)
如何使它们跨浏览器工作,以便垂直旋转,垂直位于单元格底部,水平居中,并占用最小宽度?
我使用的代码是从this answer略有修改,让它在Chrome中工作:
table { border-collapse:collapse; font-family:sans-serif }
thead th {
/* Rotate vertical: https://stackoverflow.com/a/47245068 */
-ms-writing-mode:tb-rl;
-webkit-writing-mode:vertical-lr;
writing-mode:vertical-rl;
transform:rotate(180deg);
vertical-align:middle;
text-align:left;
padding:0.5em 0 0 0;
opacity:0.5;
font-size:90%;
}
tbody th { text-align:right; padding-right:0.5em }
tbody td { text-align:center; padding:0 0.2em }
.yes { font-weight:bold; color:#060 }
.maybe { color:#440 }
.no { color:#500 }
<table><thead><tr>
<th></th>
<th class="yes">yes</th>
<th class="maybe">maybe</th>
<th class="no">no</th>
<th>who?</th>
</tr></thead><tbody><tr>
<th>Fri, Dec 9, 12pm</th>
<td class="yes">2</td><td class="maybe">1</td><td class="no">1</td>
<td><button>≡</button></td>
</tr><tr>
<th>Wed, Dec 14, 12pm</th>
<td class="yes">4</td><td class="maybe">0</td><td class="no">0</td>
<td><button>≡</button></td>
</tr><tr>
<th>Fri, Dec 16, 12pm</th>
<td class="yes">0</td><td class="maybe">0</td><td class="no">1</td>
<td><button>≡</button></td>
</tr></tbody></table>
1条答案
按热度按时间gmol16391#
在Chrome、Firefox和iOS Safari上进行了测试,这似乎对我很有效: