1

The idea is, in a table, inside a td put a line in the middle of such, like this:

1

That you can write in it and the line stays there, like a "line background", but inside the td

Any ideas?

Community
  • 1
  • 1
urco
  • 189
  • 1
  • 5
  • 16
  • What is your question and what have you tried so far? – Nico O Mar 01 '14 at 18:41
  • 1
    Yea pretty fancy, did you tried? – Mr. Alien Mar 01 '14 at 18:41
  • Not the best solution but what about canvas or background image – Hessam Mar 01 '14 at 18:42
  • @NicoO Give me the code, that's the question – Mr. Alien Mar 01 '14 at 18:42
  • @Mr.Alien That is a pretty good question indeed – Nico O Mar 01 '14 at 18:44
  • @NicoO Basically, i want to do a music sheet in a table, with the C,D,E... and, if you know about music, the notes are placed down, up and in the line, so when is up and down i use the css border-top, border-bottom, in the middle is the problem – urco Mar 01 '14 at 18:55
  • By now i try to do a line by text-decoration, but it doesn't work when is no words in it, draw a line by css and try to move a border to the middle, that's all – urco Mar 01 '14 at 18:57
  • possible duplicate of [Strikeout an entire table row](http://stackoverflow.com/questions/1204677/strikeout-an-entire-table-row) – Phrogz Mar 01 '14 at 21:40
  • Or http://stackoverflow.com/questions/4619542/linethrough-strikethrough-a-whole-html-table-row – Phrogz Mar 01 '14 at 21:49

4 Answers4

8

There are many ways

1) Add HTML <strike> or <del>.

2) use css property, text-decoration: line-through;

3) Using CSS:

td{
    border: 1px solid black;
    position: relative;
}

td:after{
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background-color: black;
    position: absolute;
    top: 50%;
}

Working Fiddle

EDIT: Since there is a bug in firefox related to position: relative and td element, wrap the text in a div of each td and use the same above css.

Working Fiddle

EDIT 2: In the comments below, @NicoO showed that the firefox bug can be resolved by giving line-height: 0 to the tr element.

Working Fiddle

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
2

Here is the working one - Result Fiddle

HTML

<td><i class="line"></i>This Is demo Text</td>

CSS

.line{
    width:100%;
    height:0;
    border-bottom:1px solid #111;
    float:left;
    margin:0;
    position:absolute;
    z-index:0;
    top:50%;
    left:0
}
M B Parvez
  • 808
  • 6
  • 16
0

You can try to create an image (1px width and height of your td) and use background-image property in css like this:

td{
    background-image: url('relative/path/to/your/image');
}
Fabien
  • 548
  • 7
  • 18
0

I just tested doing it with a span, and it worked, but other solutions might be much more elegant.

http://codepen.io/anon/pen/GAlFr

Erik Lumme
  • 5,202
  • 13
  • 27