css box-shadow para a linha da tabela?
Oct 14 2020
Aqui está meu código HTML:
<style>
.yellow{
background-color: yellow;
}
td{
width:40px;
}
tr:first-child {
box-shadow: 1px 1px 5px 5px #d99292;
}
</style>
<table>
<tr>
<td class=yellow>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td class=yellow>4</td>
</tr>
</table>
O objetivo é ter uma sombra projetada ao redor da primeira linha. O problema é que a cor de fundo da célula 4 está obscurecendo-o.
Minha pergunta é: como faço para mostrar o drop show no topo do plano de fundo da célula 4?
editar: veja a pergunta de acompanhamento: css inset box-shadow para a linha da tabela?
Respostas
3 TemaniAfif Oct 14 2020 at 02:43
Diminua o índice z das próximas células:
.yellow {
background-color: yellow;
}
td {
width: 40px;
}
tr:first-child {
box-shadow: 1px 1px 5px 5px #d99292;
}
tr:first-child + tr td {
position: relative;
z-index: -1;
}
/* the below is not mandatory but to make sure
the cells doesn't go below the table */
table {
position:relative;
z-index:0;
}
<table>
<tr>
<td class=yellow>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td class=yellow>4</td>
</tr>
</table>
O que significa um erro “Não é possível encontrar o símbolo” ou “Não é possível resolver o símbolo”?
Christopher Nolan uma vez se arrependeu de ter lido o 'roteiro de Pulp Fiction' de Quentin Tarantino