继承 td 的高度

266 阅读1分钟

通常继承高度 需要给表设置高度,但是有的时候表是没有高度的

如何在没有表高度的时候实现继承高度呢?

答案是使用 定位

 td{
    position: relative;
    height: 100%;
    vertical-align: top;
    box-sizing: border-box;
}

td>div{  
  height: 100%;
  width: 100%;
  background: red;
  position: absolute;
  box-sizing: border-box;
  top: 0;
  left: 0;
}

效果如下

image.png