4

I'm trying to use the CSS strikethrough effect described here: https://stackoverflow.com/a/14593540/62072 with a TD element, but it seems to go a bit wrong in Firefox..

Chrome

enter image description here

Firefox

enter image description here

CSS

.strikethrough
{
    position: relative;
}

    .strikethrough:before
    {
        position: absolute;
        content: "";
        /*width: 170%;*/
        /*left: -35%;*/
        left: 0;
        top: 50%;
        right: 0;
        border-top: 1px solid #333333;
        /*border-color: inherit;*/
        -webkit-transform: rotate(-35deg);
        -moz-transform: rotate(-35deg);
        -ms-transform: rotate(-35deg);
        -o-transform: rotate(-35deg);
        transform: rotate(-35deg);
    }

HTML

<span class="strikethrough">
    Test
</span>
<table>
    <tr>
        <td class="strikethrough">
            5
        </td>
    </tr>
</table>

Here is a JSFiddle to demonstrate: http://jsfiddle.net/Ms4Qy/

Any idea why this might be?

Community
  • 1
  • 1
Tom Hunter
  • 5,195
  • 8
  • 47
  • 74

1 Answers1

2

FF is known to have some strange behaviors with absolute elements inside element with display of table-cell.

The following setting might do the work (but it might cause some other problems with the table cells):

.strikethrough
{
    display: inline-block;
}

jsFiddle Demo

Itay
  • 16,048
  • 2
  • 46
  • 67
  • Thanks @Itay. Unfortunately the `inline-block` style did cause other problems with the table cells, so I ended up just putting `` elements in the table cells and applying the style to them. – Tom Hunter Sep 23 '13 at 14:31
  • @TomHunter What you've written is a very common solution for such cases (unfortunately). – Itay Sep 23 '13 at 15:04