Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2012, 04:44
julioherce
 
Fecha de Ingreso: febrero-2012
Mensajes: 2
Antigüedad: 12 años, 2 meses
Puntos: 0
Pregunta Div cuya altura crezca con el contenido

Hola a todos. Estoy desarrollando una layout que consta de una cabecera (100px de altura) y tres columnas. De esas 3 columnas, 2 serán de ancho fijo. La izquierda y la derecha(150px), la de enmedio será variable según el tamanyo de la ventana, es decir ocupará el resto del ancho.

Quiero que cada una de las columnas llegue hasta abajo aunque no tenga contenido (esto ya lo he conseguido con un script de javascript) pero lo que no consigo es que cuando el contenido es mayor que el tamanyo del div, este se extienda.

Este es mi código html y el script de javascript.

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  4.     <title>Tricky Layout</title>
  5.     <link rel="stylesheet" type="text/css" href="style.css" />
  6.     <script type="text/javascript">
  7. //<![CDATA[
  8. function sniffer() {
  9.    var windowHeight=document.documentElement.clientHeight-100+"px"
  10.     var content=document.getElementById("content");
  11.     content.style.height= windowHeight;
  12. }
  13. onload=sniffer;
  14.  
  15. //]]>
  16.  
  17. <script type="text/javascript">
  18. window.onresize = function() {
  19. sniffer();
  20.  };
  21. </head>
  22. <div id="wrapper"> 
  23.     <div id="top-column"><p>top-column</p></div>
  24.     <div id="content">
  25.         <div id="left-column"><p>left-column</p></div>
  26.        
  27.         <div id="right-column"><p>right-column</p></div>   
  28.         <div id="main-column"><p>main-columnLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  29.                             Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  30.                             Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  31.                             Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  32.                             </p></div>
  33.     </div>
  34.     <div id="clearer"></div>
  35. </div>     
  36.        
  37. </body>
  38. </html>

Y aquí está el CSS:

Código CSS:
Ver original
  1. html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  2.         margin: 0;
  3.         padding: 0;
  4.         border: 0;
  5.         font-size: 100%;
  6.         font: inherit;
  7.         vertical-align: baseline; }
  8. html, body{height: 100%; width:100%;}
  9.  
  10. div {}
  11.  
  12. #wrapper{width:100%;height:100%;}
  13.  
  14. #top-column{ height:100px;width:100%;background-color: red;}
  15.  
  16. #content{width:100%;height:100%;height:auto;}
  17.  
  18. #left-column{height:100%;float:left;width:150px;background-color: blue;min-height:100%;height: auto!important;}
  19.  
  20. #main-column{width:auto; height:100%;background-color:yellow;min-height:100%;height: auto!important;}
  21.  
  22. #right-column{height:100%;float:right;width:150px;background-color: green;min-height:100%;height: auto!important;}
  23.  
  24. #clearer{clear:both;}

Gracias de antemano!

Última edición por julioherce; 22/02/2012 a las 05:17