Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why border is not visible with "position: sticky" when background-color exists?

position: 'sticky' landed in Chrome 56, but it makes the border invisible in certain circumstances.

Consider the following example:

table {    border-collapse: collapse;  }    thead {    position: sticky;    top: 0;  }    th {    background-color: #fff;    border-right: 5px solid red;  }
<table>    <thead>      <tr>        <th>First</th>        <th>Second</th>        <th>Third</th>      </tr>    </thead>  </table>

In Chrome 56.0.2924.76, only the last <th>'s border is visible, and this is only when <th> has a background-color specified.

Is this a bug in Chrome?

Playground

like image 864
Misha Moroshko Avatar asked Jan 26 '17 20:01

Misha Moroshko


Video Answer


1 Answers

I faced the same problem. My workaround was to use the :after pseudo element to emulate a bottom border.

th:after{   content:'';   position:absolute;   left: 0;   bottom: 0;   width:100%;   border-bottom: 1px solid rgba(0,0,0,0.12); } 
like image 182
Eric Guan Avatar answered Oct 15 '22 06:10

Eric Guan