Foros del Web » Creando para Internet » CSS »

Imposible adaptar height de DIV izq con respecto al DIV contenidos

Estas en el tema de Imposible adaptar height de DIV izq con respecto al DIV contenidos en el foro de CSS en Foros del Web. Hola tengo un gran problema que no he podido solucionar. Se trata de que tengo un div o bloque izquierdo para el menu, este debería ...
  #1 (permalink)  
Antiguo 07/09/2006, 19:53
 
Fecha de Ingreso: noviembre-2003
Mensajes: 798
Antigüedad: 20 años, 4 meses
Puntos: 8
Imposible adaptar height de DIV izq con respecto al DIV contenidos

Hola tengo un gran problema que no he podido solucionar.

Se trata de que tengo un div o bloque izquierdo para el menu, este debería adaptarse a la altura del div o bloque de contenido.

en el fondo son dos columnas una a la izquierda y otra a la derecha, en la derecha debe mostrar contenido el cual este es variable y el de la derecha debería adaptar su height dependiendo del contenido de otro bloque.

este es el codigo:
Código PHP:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>footerStick Footer sticks to bottom of page</title>

<
style>
html,body {
    
height:100%;
}

#contenedor{
    
width100%;
    
heightauto;
    
background-color#ECF3F6;
    
border1px solid red;
}


#menu_izda{
    
floatleft;
    
width250px;
    
margin0;
    
background-colorred;
    
height100%;
    
border1px solid blue;
}


#contenido{
    
margin-left254px;
    
heightauto;
    
background-color:#cccccc;
    
border1px solid yellow;
}

</
style>

</
head>

<
body>

<
body>
 <
div id="contenedor">

    <
div id="menu_izda">
    
Left Col<br>
    
This is content of the LEFT columnIt can be shortlonger or very longThis is content of the LEFT columnIt can be shortlonger or very longThis is content of the LEFT columnIt can be shortlonger or very long.
    </
div>


    <
div id="contenido">
        
Contenido<br>
        
This is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very long.
        
This is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very longThis is content of the MIDDLE columnIt can be shortlonger or very long.
    </
div>


</
div>
</
body>
</
html

Última edición por zsamer; 07/09/2006 a las 20:55
  #2 (permalink)  
Antiguo 07/09/2006, 20:57
Avatar de jesusbet
(Desactivado)
 
Fecha de Ingreso: mayo-2004
Ubicación: Monterrey, MX
Mensajes: 2.667
Antigüedad: 19 años, 11 meses
Puntos: 2
Comúnmente, no se puede hacer tal como uno quiere, sin embargo, se puede conseguir el efecto.

Solo usamos un background para el contenedor de las dos columnas, luego usas la técnica del 'clearfix' para que el contenedor de los flotados se extienda por igual (así no depende del elemento no-flotado).

De esa manera se 'engaña' al usuario, no tienes dos divs del mismo tamaño, pero sí haces que se vea así.

Por otro lado, no sé el uso que le vas a dar, así que igual y esto no te sirve, si quieres dinos que uso le darás para buscar una solución más adecuada.

Por cierto, el efecto que te digo puedes verlo en:
http://www.uanl.mx/vinculacion/

Si te das cuenta, hay un borde que divide a la barra izquierda y derecha del contenido, ese es un background del contenedor general (no de cada barra, ni del contenido).

Saludos
  #3 (permalink)  
Antiguo 07/09/2006, 22:00
 
Fecha de Ingreso: noviembre-2003
Mensajes: 798
Antigüedad: 20 años, 4 meses
Puntos: 8
el uso es simple en el bloque de la izquierda esta el menu y en el bloque de la derecha del menu esta el contenido de noticias.

el contenido de noticia es variable, por eso necesito ajustar la altura del bloque de la izquierda(menu) a la altura(height) del bloque del contenido de noticias (noticia detalle).

eso es a grandes rasgos, es decir que el bloque de la izquierda se ajuste a la altura del de la derecha.

Mi problema es el mismo que se planteó en este topico, pero no se resolvió ya que se transformo en una pelea de tablas v/s css, al final quedó inconclusa la solución

salu2
  #4 (permalink)  
Antiguo 07/09/2006, 22:07
Avatar de jesusbet
(Desactivado)
 
Fecha de Ingreso: mayo-2004
Ubicación: Monterrey, MX
Mensajes: 2.667
Antigüedad: 19 años, 11 meses
Puntos: 2
Bueno, sí, eso lo había entendido, pero yo pensaba en que aclararas un poco más el uso que le vas a dar, es decir, si es por un mero diseño (donde un borde tiene que llegar hasta abajo), puedes hacer lo que te digo...

Saludos
  #5 (permalink)  
Antiguo 07/09/2006, 22:48
 
Fecha de Ingreso: noviembre-2003
Mensajes: 798
Antigüedad: 20 años, 4 meses
Puntos: 8
lo que necesito es que el height con el fondo rojo del div de la izquierda(menu) llegue hasta donde termina (bottom) del div de la derecha(noticias), es decir el heigh no tiene que llegar hasta abajo de la pagina, tiene que llegar hasta donde llega el contenido del div de la derecha.

esa es la idea, la altura tiene que ser cimetrica en ambos contenedores.


salu2
  #6 (permalink)  
Antiguo 07/09/2006, 23:07
 
Fecha de Ingreso: diciembre-2003
Mensajes: 1.583
Antigüedad: 20 años, 3 meses
Puntos: 13
Otra solución es utilizar mediante Javascript. Te explico la teoría para que luego preguntes en el foro de Javascript.
  1. Ambos DIV's deben tener su correspondiente atributo ID para identificarlos
  2. Luego de que ha cargado por completo la página (evento onload) debes capturar la altura actual de ambos DIV's
  3. Comparas ambas alturas para ver cual de las 2 es mayor
  4. Al que tiene menor altura le debes asignar la misma altura que el otro. Esto lo logras redefiniendo su altura mediante CSS (utilizando Javascript obviamente).

nota: en el paso 3 debes tomar algunas precausiones, ya que para algunos browsers (como firefox) deberás utilizar la propiedad min-height, mientras que en otros (como IE) deberás utilizar la propiedad height. Esto porque si en firefox utilizas height la nueva altura quedará fija, y si el usuario aumento el tamaño de letra el DIV no crecerá a la par del texto, el cual lo rebalsará.
  #7 (permalink)  
Antiguo 08/09/2006, 08:52
Avatar de jesusbet
(Desactivado)
 
Fecha de Ingreso: mayo-2004
Ubicación: Monterrey, MX
Mensajes: 2.667
Antigüedad: 19 años, 11 meses
Puntos: 2
aaah ya, entonces sí, puedes usar la técnica que te digo, mira esta página:
http://www.gettintranet.com/

Es lo que buscas hacer (pero en tu página el menú está a la izquierda).

Usa la técnica que te digo (ponle un background al contenedor de las dos columnas; dicho background será la imagen del background del contenido y del sidebar, en el caso que te puse arriba, esta es la imagen), es CSS puro y no necesitas javascript.

Saludos
  #8 (permalink)  
Antiguo 08/09/2006, 14:41
 
Fecha de Ingreso: noviembre-2003
Mensajes: 798
Antigüedad: 20 años, 4 meses
Puntos: 8
como dices jesusbet funciona pero lo que ando buscando es que la altura del div de la izquierda se ajuste en forma automatica a la altura del div de la derecha, eso es lo ideal que ando buscando.

grax y salu2
  #9 (permalink)  
Antiguo 08/09/2006, 16:37
Avatar de opeth  
Fecha de Ingreso: junio-2004
Ubicación: Distrito Federal, México
Mensajes: 338
Antigüedad: 19 años, 10 meses
Puntos: 0
¿como esto?

ejemplo

explicación

otro método

Equal Height Columns

y este creo que es como dice jesusbet

Faux Columns

Saludos

Actualización: corregi un enlace que estaba mal

Última edición por opeth; 08/09/2006 a las 18:12
  #10 (permalink)  
Antiguo 08/09/2006, 18:03
 
Fecha de Ingreso: noviembre-2003
Mensajes: 798
Antigüedad: 20 años, 4 meses
Puntos: 8
Gracias opeth , es justo lo que necesitaba.

saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:32.