2011-02-23 29 views
20
<table cellspacing="0" id="contactTable" style="table-layout:table-layout:fixed;; width:100%; font-weight:normal; position: absolute; top:45; left: 0;"> 

<td height="50" style="padding-left:5px; overflow:hidden; "> 
    <span style="text-transform:capitalize;line-height:100%;"> 
    //names here 
    </span>       
    </td> 

...more code 
</table> 

Esto no funciona. El desbordamiento sigue haciendo que la celda sea más alta, la altura se está adaptando al contenido.CSS cómo hacer <TD> una altura fija?

+4

Se utiliza TR, ¿verdad? –

+0

@ Šime Vidas - claramente no :) –

+2

@ Šime Vidas sí. Simplemente no lo pegué aquí – Dave819

Respuesta

29

La mejor solución es poner un div dentro de la célula con la altura:

<td style="padding-left:5px;"> 
    <div style="height: 50px; overflow:hidden;"> 
     ... 
    </div> 
</td> 

Por cierto, ¿cuál es el lapso de? Si solo lo necesita para el diseño, puede darle estilo a la celda directamente.

+0

agradable .......... – Newkie

-1

¿Ha intentado establecer la altura de css en el td en lugar del atributo html?

<td style="padding-left:5px; height:50px; overflow:hidden; "> 
    <span style="text-transform:capitalize;line-height:100%;"> //names here 
    </span>        

+0

Sí. No funciona la celda aún se hace más alta si hay un montón de texto – Dave819

-5

habría escrito

<td style="height:50px"> 
... 
</td> 
1

se está perdiendo filas de la tabla


<table cellspacing="0" id="contactTable" style="table-layout:fixed; width:100%; font-weight:normal; position: absolute; top:45; left: 0;"> 
    <tr> 
     <td style="padding-left:5px; overflow:hidden; height: 50px;"> 
      <span style="text-transform:capitalize;line-height:100%;"> 
       //names here 
      </span>       
     </td> 
    </tr> 
</table> 
0

La propiedad CSS que busca es line-height. Simplemente hay que ponerlo en el <td>, no en el contenido <span>

<td style="padding-left:5px; line-height: 50px; overflow: hidden"> 
</td> 
0

que tenía este mismo problema. Puedes usar el lapso directamente. Es el mejor enfoque. El TD/TR no respeta la altura establecida. Simplemente ponga una clase en su tramo y agregue el CSS o simplemente apliqúelo directamente con el atributo de estilo.

<span class"MyClass">LONG NAME</span> 

.MyClass { //on CSS File 
    height: 60px; 
    overflow:hidden; 
} 

o simplemente

<span style="height: 60px; overflow:hidden;">LONG NAME</span> 
Cuestiones relacionadas