Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/09/2012, 08:23
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: positionar thead siempre arriba de tbody

Cita:
Lo que desearia es ubicar el tbody por debajo del thead.
Pero ese es el orden natural. Distinto si dijeras que querés posicionar el thead por debajo del tbody

Ejemplo
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <style type="text/css">
  7. thead {
  8. color:green;
  9. position:absolute;
  10. left:0;
  11. top: 60px;
  12. }
  13. tbody {color:blue;
  14. position:absolute;
  15. left:0;
  16. top:0;
  17. }
  18. tfoot {color:red;
  19. position:absolute;
  20. left:0;
  21. top:200px;
  22. }  
  23.  
  24. td, th{
  25. border: solid 1px #000;
  26. }
  27.  
  28.  
  29.  
  30. </head>
  31.  
  32.   <thead>
  33.     <tr>
  34.       <th>Código</th>
  35.       <th>Valor</th>
  36.     </tr>
  37.   </thead>
  38.   <tfoot>
  39.     <tr>
  40.       <td>A+B</td>
  41.       <td>3</td>
  42.     </tr>
  43.   </tfoot>
  44.   <tbody>
  45.     <tr>
  46.       <td>A</td>
  47.       <td>1</td>
  48.     </tr>
  49.     <tr>
  50.       <td>B</td>
  51.       <td>2</td>
  52.     </tr>
  53.   </tbody>
  54. </body>
  55. </html>

o incluso automatizarlo, si no conocés el alto que te va a ocupar el tbody, pero eso ya sería con javascript, ejemplo

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <style type="text/css">
  7. thead {
  8. color:green;
  9. position:absolute;
  10. left:0;
  11. }
  12. tbody {color:blue;
  13. position:absolute;
  14. left:0;
  15. top:0;
  16. }
  17. tfoot {color:red;
  18. position:absolute;
  19. left:0;
  20. top:200px;
  21. }  
  22.  
  23. td, th{
  24. border: solid 1px #000;
  25. }
  26.  
  27.  
  28.  
  29. </head>
  30.  
  31.   <thead id="the">
  32.     <tr>
  33.       <th>Código</th>
  34.       <th>Valor</th>
  35.     </tr>
  36.   </thead>
  37.   <tfoot>
  38.     <tr>
  39.       <td>A+B</td>
  40.       <td>3</td>
  41.     </tr>
  42.   </tfoot>
  43.   <tbody id="tb">
  44.     <tr>
  45.       <td>A</td>
  46.       <td>1</td>
  47.     </tr>
  48.     <tr>
  49.       <td>B</td>
  50.       <td>2</td>
  51.     </tr>
  52.   </tbody>
  53. <script type="text/javascript">
  54. //<![CDATA[
  55. var Htbody =document.getElementById("tb").offsetHeight;
  56. var alto = Htbody+50;
  57. document.getElementById("the").style.top = alto +'px';
  58. //]]>
  59. </body>
  60. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.