I like Nicole Morgan Erickson's answer , but it can cause side effects if your project runs it verbatim. I added some small tweaks to keep this kosher down ... so we don’t globally change every table or every td with this css .
I also wanted the button in the line to cross out the line, but I did not want to cross out the column with the button, for the sake of visibility. I just wanted to cross out the rest of the line. To do this, I made sure that every column that would like to show a strike must declare it, also being marked with a class. In this iteration, you will need to mark the table as successful, as well as mark each td as successful; but you get security without creating side effects that may not be useful for the tables, and you get control over which columns to cross out.
CSS
table.strike-able { border-collapse: collapse; } table.strike-able tr td { position: relative; padding: 3px 2px; } table.strike-able tr th { position: relative; padding: 3px 2px; } table.strike-able tr.strikeout td.strike-able:before { content: " "; position: absolute; top: 50%; left: 0; border-bottom: 2px solid #d9534f; width: 100%; }
Application:
<table class="strike-able" id="Medications" data-item-count="@Model.Medications.Count"> <tr> <th> Some Column </th> <th> Command Column </th> </tr> <tr class="strikeout"> <td class="strike-able"></td> <td>Button that Toggles Striking Goes Here (active)</td> </tr> <tr> <td class="strike-able"></td> <td>Button that Toggles Striking Goes Here</td> </tr> </table>
Finally, since I use this with Bootstrap and see removal as a dangerous thing, I formatted the colors a bit to fit my usage.
Greg Jul 22 '15 at 21:40 2015-07-22 21:40
source share