Jump to content

position one div at the bottom of another?


michaellunsford

Recommended Posts

basically:

[code=php:0]<div style="float:right; width:500px; height: 400px">some content
<div style="bottom:0px">should be on the bottom of this div</div>
</div>[/code]


if I add "position:fixed;" or "position:absolute;" it will be centered left-to-right under the DIV, but it's at the bottom of the screen, outside the div.
Link to comment
Share on other sites

you need to use positioning.

NOW the div you want to be at the bottom of a parent div use:

div#bottom{position: absolute; left: 0; bottom: 0;}

now normally that would put it at the bottom of the screen but in this case you need to assign position to parent element so try:

div#parent{position: relative; top: 0; left: 0;}

That shoudl do the trick for you.
Link to comment
Share on other sites

I tried it, but without the spacer div, the bottom just snuggles up to the content in the parent div.


[b]the plot thickens[/b]: the height of the child DIV is not stretching to accommodate the contents of the child (probably because the child's overflow isn't set correctly). If I set the child's overflow to auto, I get a scrollbar. How do I set overflow to stretch the height?

[code]#parent { height:auto; width:500px; background:url(/images/bgimage.jpg) repeat-x #069; }
#child {height:450px; width:500px; }
<div id="parent">
<div id="child">enough content to be higher than 450px</div>
<div>displays on the bottom</div>
</div>[/code]

Link to comment
Share on other sites

found this very good tutorial in google (just had to figure out what words to search for).

http://www.greywyvern.com/code/min-height-hack.html

and, despite the title, it's not a "hack" so much as a common sense method to achieve the goal -- creating a minimum-height without using the "min-height" property (which doesn't work in my browser anyway).

[b]so now[/b] if I can only figure out how to make my left column DIV the same height as the newly stretched right column DIV. hmmmmm...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.