Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colspan doesn't work with <td> width set? (IE7)

I can't get colspan to work when I use a fixed width (IE 7)? Why?!

Sample Code:

<html>
  <head>
    <style>
    .inputGroup td
    { width:250px; }    
    </style>
  </head>
<body>
<table class="inputGroup">
  <tr>
    <td>cell1</td>
    <td>cell2</td>
  </tr>
  <tr>
    <td colspan="2">This should span two columns but it doesnt</td>
  </tr>
  <tr>
    <td>cell1</td>
    <td>cell2</td>
  </tr>
</table>
</body>
</html>

Help anybody? :(

like image 416
Alex Avatar asked Jun 03 '09 23:06

Alex


2 Answers

it does, but you've limited the width. If you want, try creating another class called '.doubleSpanInputGroup' or something with width 500 and set that class onto the spanning column.

eg.

<html>
  <head>
    <style>
    .inputGroup td
    { width:250px; }   
    .inputGroup td.doubleInputGroup
    { width:500px; } 
    </style>
  </head>
<body>
<table class="inputGroup">
  <tr>
    <td>cell1</td>
    <td>cell2</td>
  </tr>
  <tr>
    <td colspan="2" class="doubleInputGroup">This should span two columns but it doesnt</td>
  </tr>
  <tr>
    <td>cell1</td>
    <td>cell2</td>
  </tr>
</table>
</body>
</html>

EDIT: made the new style more hierarchical

like image 64
Luke Schafer Avatar answered Oct 24 '22 07:10

Luke Schafer


Try making the rule apply to tr instead of td and make the width 500px instead, as such:

.inputGroup tr { width: 500px; }

The problem you're having is because you've set a limit on the td to be at most 250px wide, so the browser is simply following your instructions.

like image 40
Deniz Dogan Avatar answered Oct 24 '22 08:10

Deniz Dogan