user1364110
user1364110

Reputation: 1

Dynamically created div poistioning issue

I am creating divs in the following heirachy

<div class="box">
Content goes here
<div class="footer>Footer</div>
</div>
<div class="box">
Content goes here
<div class="footer>Footer</div>
</div>
<div class="box">
Content goes here
<div class="footer>Footer</div>
</div>

The main box "box" is scrollable. I want the footer "footer" to remain bottom of the parent container i,e "box". I am googling for three days. None worked. Very anxious. Please help

Upvotes: 0

Views: 77

Answers (1)

tienrocker
tienrocker

Reputation: 194

you must use position absolute and bottom 0 like Sarfraz said above.

here is sample code:

<html> 
<head> 
<style>
body { width:100%;}
.box { float: left; height: 200px; margin-right: 5%; position: relative; width: 20%;}
.footer {bottom: 0px; position: absolute; width: 100%; text-align: center;}
.box_content{ height: 180px; overflow-y: scroll;}
.clear { clear:both;}
</style> 
</head> 
<body> 
<div class="box">
    <div class="box_content">
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
    </div>
    <div class="footer">Footer</div>
</div>
<div class="box">
    <div class="box_content">
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
    </div>
    <div class="footer">Footer</div>
</div>
<div class="box">
    <div class="box_content">
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
        Content goes here <br />
    </div>
    <div class="footer">Footer</div>
</div>  
<div class="clear"> </div> 
</body> 
</html>

Upvotes: 1

Related Questions