2009-06-03 16 views
5

No puedo hacer que Colspan funcione cuando uso un ancho fijo (IE 7)? ¡¿Por qué?!Colspan no funciona con <td> ancho establecido? (IE7)

Código de ejemplo:

<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> 

ayudar a nadie? :(

Respuesta

7

que hace, pero usted ha limitado el ancho. Si lo desea, intente crear otra clase llamada '.doubleSpanInputGroup' o algo con un ancho de 500 y establecer esa clase en la columna de expansión.

por ejemplo.

<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: hizo el nuevo estilo más jerárquica

+0

Oh wow. Gracias, a veces simplemente no ves lo que está justo en frente tuyo. – Alex

+0

Sí, no hay problemas, error fácil. Por favor, asegúrese de usar mi versión revisada arriba ya que el primer pase tuvo un pequeño problema :) woops. –

1

Intente hacer la regla se aplica a tr en lugar de td y hacer que el ancho de 500px en su lugar, como tal:

El problema que tiene es que ha establecido un límite en el td para que tenga como máximo 250 píxeles de ancho, por lo que el navegador simplemente sigue sus instrucciones.

0

de manera general:

table tr:first-child td:first-child{ width:86px; } 

si este es el único ancho de todo primera columna de tomar este anchura y colspan en ie7 trabajará

0

I tratado de establecer la anchura de las células colspan a auto, parecía funcionar bien en IE7/8/9

.yourColSpanTD { width: auto !important; } 
Cuestiones relacionadas