Cómo crear dos columnas iguales con un espacio fijo en el medio

Tengo una mesa con width:100% and it should have 3 columns as follows:

[50%-space/2][space][50%-space/2]

Now, I have this already

<table style="width:100%"><tr>
   <td>left</td>
   <td style="width:20px"></td> //space
   <td>right</td>
</table>

This works fine, as long as there is always a "left" and "right" width the same width, but it stops working if one has a different width:

<table style="width:100%"><tr>
   <td></td>
   <td style="width:20px"></td> //space
   <td>right</td> // right takes all the space from the first td
</table>

And if I set "left" and "right" each to 50%, the space in between is omitted:

<table style="width:100%"><tr>
   <td style="width:50%"></td>
   <td style="width:20px"></td> //space
   <td style="width:50%">right</td> // right takes all the space from the first td
</table>

Unfortunately, the space cannot be in % in this case (which would solve the problem easily). Also using CSS columns is not (yet) an option.

¿Existe alguna solucion para esto?


JSFiddle


preguntado el 28 de mayo de 14 a las 13:05

Any additional option which does not require a <table> is welcomed, as long as it does not use CSS columns. -

Why don't you want to use "CSS columns" ? You're already using CSS, right ? -

1 Respuestas

Ejemplo: http://jsfiddle.net/9yVx9/1/


utilizan el table-layout: fixed perfecta

table {
    table-layout:fixed;
}

Captura de pantalla enter image description here

contestado el 28 de mayo de 14 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.