Stacking a table with a single pop-up column while maintaining semantically correct layout

I want to create a table with the following view:

Four-column table with second column larger than others

It might look easy at first, but actually it is not:

  • The background image is complex because it spans multiple elements without a common parent
  • Table cells should have abnormal sizes that usually don’t like
  • The hover overlay should exclude the portion of the column that sticks out

Here is the fiddle base you can use for testing. It contains basic markup + styles for the table. All without abnormal table cells and hover effects.

:before td :after 0.5 multiply.

background-position. 0, 100%, 200% .. .

, . . . :

  • :after tr. , , block ( table-row ). , min-width , , . .
  • background-position , , , . , .

, , 4 JavaScript . ? .. <table>.


.

+4
1

,

, pseduo. , , . , .

, , .

.container {
    margin: 20px;
    overflow: hidden;
}

table {
    margin: 10px 10px 20px 10px;
    background: #F0F6F7;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.16);
    border-radius: 5px;
    border-collapse: collapse;
}


tr:hover td {
    background: rgba(255, 0, 0, 0.2);
}

tr + tr td, tr + tr td.pop:before {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}


tr:first-child .pop:after, tr:first-child .pop:before {
    top: -10px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

tr:last-child .pop:after, tr:last-child .pop:before {
}

td {
    min-width: 150px;
    box-sizing: border-box;
    padding: 16px 10px 15px 10px;
    color: #787878;
    font-family: Roboto, sans-serif;
    font-size: 16px;
    text-align: center;
}

td + td {
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

td.pop {
    position: relative;
    z-index: 0;
    color: #FFF;
}

td.pop, td.pop + td {
    border-left: none;
}

tr:first-child td.pop:after {
    content: '';
    position: absolute;
    top: -10px;
    right: 0;
    left: 0;
    z-index: -2;
    background: url('https://i.imgur.com/lcKmrnE.jpg')  #539BFC;
    background-blend-mode: screen;
    opacity: 0.75;
    height: 1000%;
}

tr:last-child td.pop:after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    z-index: -1;
    height: 10px;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    box-shadow: 2px 2px 2px 0px lightgray, 0px 10px 0px 10px white;
}
<div class="container">
<table>
    <tbody>
        <tr><td>Josh</td><td class="pop">3 BTC</td><td>$46,343</td><td>27/12/17</td></tr>
        <tr><td>Anne</td><td class="pop">2 BTC (veeery big cell)</td><td>$38,452</td><td>26/12/17</td></tr>
        <tr><td>Jack</td><td class="pop">6 BTC<br><small>bigger</small></td><td>$126,989</td><td>26/12/17</td></tr>
        <tr><td>Gyumur</td><td class="pop">0.7 BTC</td><td>$14,104</td><td>24/12/17</td></tr>
        <tr><td>Boggy</td><td class="pop">12 BTC</td><td>$267,766</td><td>21/12/17</td></tr>
    </tbody>
</table>
</div>
Hide result
+1

Source: https://habr.com/ru/post/1691478/


All Articles