0

Good Day
i have this issue

<table border="1" width="100%">
<tr>
<td>a</td><td>a</td></tr>
<tr>
<td>a</td><td>a</td></tr>

<tr>
<td colspan="2">b</td>

</tr>
<tr><td class="test">c</td></tr>


</table>

You can see here http://jsfiddle.net/GfQyg/


What i want to do is :
use css in class "test" to add colspan to the last row so it fits the table
is it possible ?

i dont want to modify the html


i need only to modify the css
Thank you
user1000744
  • 123
  • 1
  • 4
  • 12
  • Why wouldn't you use colspan? It's valid? – Menno May 08 '13 at 08:35
  • Just for my curiosity, why do you want to do the colspan by css provided that td is already giving you that option? I really cannot imagine your purpose for doing that. EDIT: Agreed with @Aquillo You can check the fiddle with td as colspan and the obvious output that you can get. http://jsfiddle.net/GfQyg/1/ – Nitesh May 08 '13 at 08:36
  • If you can't change html then use javascript to add the colspan. – me_digvijay May 08 '13 at 08:45

2 Answers2

0

You can use the CSS3 column-span column-span link

But I suggested to use colspan.

Lian
  • 1,597
  • 3
  • 17
  • 30
  • are you sure? As I saw your link with NO FIREFOX COMPATIBILITY as well as not an ideal colspan solution for tables. Can you do a Fiddle and send me your research link? I will be curious to know how do you do it taking the same question as posted by user1000744. - @newbie – Nitesh May 08 '13 at 08:42
  • I provided a link and you can test it there. – Lian May 08 '13 at 08:44
  • i have done all my changes based on row background, but in chrome, this background was repeating in each cell, so i moved to cell background, but now i have to stretch each cell to colspan2 – user1000744 May 08 '13 at 08:48
0

you can use following script to do this: change class="test" to id="test" &

<script>
function displayResult()
{
 document.getElementById("test").colSpan="2";
}
 </script>

and call displayResult as :

<body onload="displayResult()" >
Vaibhav Jain
  • 3,729
  • 3
  • 25
  • 42