How can a split diagonally a table header cell?

时间:2017-08-04 12:13:37

标签: css html5 css3

I am trying to create a table which header is divided in 2 with a diagonal line like in the image below.

enter image description here

How can I do this?

Thanks :)

1 个答案:

答案 0 :(得分:3)

.background {
  width: 100px;
  height: 50px;
  padding: 0;
  margin: 0;
}

.line {
  width: 112px;
  height: 47px;
  border-bottom: 1px solid red;
  transform: translateY(-20px) translateX(5px) rotate(27deg);
  position: absolute;
  z-index: -1;
}

.background>div {
  position: relative;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
}

.bottom {
  position: absolute;
  bottom: 1px;
  left: 1px;
}

.top {
  position: absolute;
  top: 1px;
  right: 1px;
}
<table>
  <th class="background">
    <div><span class="bottom">First</span>
      <span class="top">Second</span>
      <div class="line"></div>
    </div>
  </th>
</table>