Foros del Web » Creando para Internet » CSS »

problema height 100%

Estas en el tema de problema height 100% en el foro de CSS en Foros del Web. @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código HTML: Ver original <!DOCTYPE html> < html lang = "en" > < head >     < meta charset = "UTF-8" > ...
  #1 (permalink)  
Antiguo 25/03/2015, 16:00
Avatar de rottenp4nx  
Fecha de Ingreso: octubre-2012
Ubicación: Santiago
Mensajes: 417
Antigüedad: 11 años, 6 meses
Puntos: 36
problema height 100%

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.     <meta charset="UTF-8">
  4.     <title>rebelArte</title>
  5. </head>
  6.     *{
  7.         padding: 0;
  8.         margin: 0;
  9.     }
  10.     html{
  11.         width: 100%;
  12.         height: 100%;
  13.     }
  14.     body{
  15.         background-color: #282828;
  16.         width: 100%;
  17.         height: 100%;
  18.     }
  19.     #container{
  20.         display: block;
  21.         width: 94%;
  22.         height: 94%;
  23.         margin: 3% 3%;
  24.         background: #fff;
  25.         min-height: 100%;
  26.        
  27.     }
  28.     <div id="container">Hola Mundo!</div>
  29. </body>
  30. </html>

Teoricamente, solo se debería rellenar y no que aparezca el scrollbar vertical
porque el body tiene 100% de altura y el hijo div container tiene 94% de alturo más los margenes de arriba y abajo de 3%, dan los 100% de altura y produce el scrollbar, me parece raro.
De antemano gracias :)

  #2 (permalink)  
Antiguo 25/03/2015, 16:19
Avatar de AngelKrak  
Fecha de Ingreso: noviembre-2014
Mensajes: 917
Antigüedad: 9 años, 5 meses
Puntos: 91
Respuesta: problema height 100%

no soy un experto en CSS pero porque 100% en html y body, si el container tiene 94%

en todo caso ponle 94% tanto al Body, como al HTML igual que al Container (ese es tu problema)

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.     <meta charset="UTF-8">
  4.     <title>rebelArte</title>
  5. </head>
  6.     *{
  7.         padding: 0;
  8.         margin: 0;
  9.     }
  10.     html{
  11.         width: 100%;
  12.         height: 94%;
  13.     }
  14.     body{
  15.         background-color: #282828;
  16.         width: 100%;
  17.         height: 94%;
  18.     }
  19.     #container{
  20.         display: block;
  21.         width: 94%;
  22.         height: 94%;
  23.         margin: 3% 3%;
  24.         background: #fff;
  25.         min-height: 100%;
  26.        
  27.     }
  28.     <div id="container">Hola Mundo!</div>
  29. </body>
  30. </html>

Demo:
http://codepen.io/AngelKrak/pen/WbPYRq
  #3 (permalink)  
Antiguo 25/03/2015, 16:41
Avatar de rottenp4nx  
Fecha de Ingreso: octubre-2012
Ubicación: Santiago
Mensajes: 417
Antigüedad: 11 años, 6 meses
Puntos: 36
Respuesta: problema height 100%

es que pienso:
El padre body -> 100% H
y el hijo div -> 94% H con 3% margin top y margin bottom 3%
debería quedar al centro de la pantalla

Gracias por tu ayuda, probaré :)
  #4 (permalink)  
Antiguo 25/03/2015, 17:11
Avatar de pzin
Moderata 😈
 
Fecha de Ingreso: julio-2002
Ubicación: Islas Canarias
Mensajes: 10.488
Antigüedad: 21 años, 8 meses
Puntos: 2114
Respuesta: problema height 100%

Si le pones una altura mínima de 100% pues te medirá al menos 100%.
__________________
(:
  #5 (permalink)  
Antiguo 25/03/2015, 18:20
Avatar de rottenp4nx  
Fecha de Ingreso: octubre-2012
Ubicación: Santiago
Mensajes: 417
Antigüedad: 11 años, 6 meses
Puntos: 36
Respuesta: problema height 100%

sin eso también pasa, se me olvidó sacarlo del código jajaj
  #6 (permalink)  
Antiguo 25/03/2015, 19:12
Avatar de ZoroRoronoa  
Fecha de Ingreso: marzo-2011
Ubicación: California, USA
Mensajes: 824
Antigüedad: 13 años, 1 mes
Puntos: 116
Respuesta: problema height 100%

al body ponle height:100%; en lugar de 94
y al #container, quitale ese min-height:100%;
__________________
Programador jQuery & PHP

Etiquetas: background, color, height, html, width
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 12:44.