Height 100% in content

Asked

Viewed 341 times

1

Hello, I’m having a height problem follow the code the world below for better understanding:

HTML:

<html>
<body>
    <div class='wrapper'>
            <div class='cabecalho'></div>
            <div class='conteudo'>
                Conteúdo
        </div>
            <div class='clear'></div>
            <div class='rodape'></div>
    </div>
</body>

CSS

html,body{
   height:100%;
}
body{
   background:lightgray;
}
.wrapper{
   height:auto;
   width:100%;
   min-height:100%;
   position:relative;
   overflow:hidden;
}
.cabecalho{
   height:50px;
   background:orange;
   width:100%;
}
.conteudo{
   padding-bottom:100px;
}
.clear{
   clear:both;
}
.rodape{
   width:100%;
   position:absolute;
   bottom:0;
   height:40px;
   background:green;
}

Fiddle in example: http://jsfiddle.net/Lnr2ftyc/1/

With this code the footer is at the bottom of the page if it has little content, and also if it has a lot of content.

The problem is that I am now using a framework that is injecting into . content a <div style='height:100%'></div> and all your parents(wrapper,body,html) are putting in the height:100 style%.

1 - Then there is the need of . content always has the height 100%(minus the part of the footer) independent of the text that has inside.

How is it: http://i.imgur.com/Zohn0Gm.png As it should be: http://i.imgur.com/ecrKFJ3.png

2 - If you have too much text/image and exceed the size of the window the footer should go to the bottom of the page (as it is currently).

inserir a descrição da imagem aqui

3 - Also has a menu that I did not put but it opens on the content side and should be the same height of the content.

4 - Everything must be IE8+ compatible (so flexbox,height:Calc cannot be used).

Thanks for the help!

  • Put the footer out of the wrapper and use a technique called Sticky Footer. Just play on Google. This can help you.

  • With the Sticky Footer technique does not solve, because when the div is inserted by the framework the footer is on top of the content. What is not the desired.

1 answer

1

The problem is that you are using 2 properties relating to heightin your div wrapper. Removing the property min-height:100%;and adding height:100%to its content, everything works right.

Here’s an example of code working: http://jsfiddle.net/rnbp2vrc/

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.