【发布时间】:2020-11-19 07:29:51
【问题描述】:
Chrome 和 Firefox
IOS 14 上的移动 Safari
Z-index 似乎被忽略了,看起来好像 pseudo elements 没有正确锚定到 tbody 元素并且远远超出其父元素。
可以进行哪些调整以使 Mobile Safari 的行为类似于 Chrome 和 Firefox?我正在使用pseudo elements 来模拟重叠表行的外观。如果不使用pseudo elements 也可以实现这种外观,那也是适合我的解决方案。
th:first-child, tbody td:first-child {
border-top-left-radius: 1.5rem;
}
th:last-child, tbody td:last-child {
border-top-right-radius: 1.5rem;
}
tbody, tbody td {
position: relative;
z-index: 10;
transform: scale( 1 );
}
tbody td {
background-color: #333;
}
tbody td:first-child, tfoot td:first-child {
border-bottom-left-radius: 1.5rem;
}
tbody td:last-child, tfoot td:last-child {
border-bottom-right-radius: 1.5rem;
}
tbody::before, tbody::after {
position: absolute;
z-index: -10;
top: 0; right: 0; bottom: 50%; left: 0;
background-color: #222;
content: "";
}
tbody::after {
top: 50%; right: 0; bottom: 0; left: 0;
background-color: #444;
}
tfoot td { background-color: #444; }
<style>
html, table, p {
margin: 0;
padding: 0 !important;
color: #ddd;
}
html {
font-family: Arial;
text-align: center;
text-transform: capitalize;
}
table, th, td {
padding: 1rem;
border-spacing: 0;
}
thead th {
background-color: #222;
}
th { text-transform: uppercase; }
td { border-bottom: solid #222; }
</style>
<table>
<thead>
<tr> <th><p>one</p></th><th><p>two</p></th><th><p>three</p></th> </tr>
</thead>
<tbody>
<tr> <td><p>four</p></td><td><p>five</p></td><td><p>six</p></td> </tr>
</tbody>
<tfoot>
<tr> <td><p>seven</p></td><td><p>eight</p></td><td><p>nine</p></td> </tr>
</tfoot>
</table>
【问题讨论】:
标签: css ios html-table mobile-safari pseudo-element