使用css3属性时table的box-shadown被覆盖问题

初学使用css3各种效果,在设置鼠标划过显示阴影时,默认<td>总是下边的阴影被上面的覆盖掉,折腾了一下发现,原来是权重的问题,刚开始加大z-index没效果,测试了好久才想起z-index属性是对定位元素才有用的,加上position:relative问题就解决了。(ps.例子有点丑,别介)

<CSS>

<style>
* {
    margin:0px;
    padding:0px;
}
table{
    empty-cells: show;
    border-collapse:separate; /*只是为了重写reset中的collapse,否则无圆角效果*/
}
#tb_sty2{
	text-align:center;
	margin:0 auto;
	font-size:16px;
	line-height:22px;
	border-top: #708090 3px solid;
	border-top-left-radius: 3px;
	border-top-right-radius: 3px;
	-moz-border-radius-topleft: 3px;
	-moz-border-radius-topright: 3px;
	-webkit-border-top-radius: 3px;
}
#tb_sty2 td{
	padding:3px;
	border-bottom: #bbb thin solid;
}
#tb_sty2 tr:hover{
	box-shadow: 0px 0px 5px 2px rgba(120, 120, 120, 0.35);
	position: relative;   /**** look here  *****/
	z-index: 10;          /**** & here  *****/
}
#tb_sty2 tr:nth-child(1) td,#tb_sty2 tr:nth-child(1) th{
    color:#F4FAFF;
    font-size:18px;
    font-family: "Microsoft YaHei";
    font-weight: bold;
    background-color:#708090 !important;
}
#tb_sty2 tr:nth-child(odd) td,#tb_sty2 tr:nth-child(odd) th{
    background: #dcdcdc;
}
#tb_sty2 tr:nth-child(even) td,#tb_sty2 tr:nth-child(even) th{
    background: #F4FAFF;
}
</style>


<HTML>

<table width="80%" border="0" cellspacing="0" cellpadding="0" id="tb_sty2" align="center">
        <tr>
            <td>公式名称</td>
            <td>公式名称</td>
            <td>公式名称</td>
        </tr>
        <tr >
            <td>公式名称</td>
            <td>公式名称</td>
            <td>公式名称</td>
        </tr>
        <tr >
            <td>公式名称</td>
            <td>公式名称</td>
            <td>公式名称</td>
        </tr>
    </table>

没加之前:(下方阴影被遮挡)

加上之后:


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值