Search code examples
javascriptcsshtmlpositioning

This is a bit abstract, but can you get a div to start at one of the bottom corners?


Maybe there's an easy answer, but I don't know it. I know you can float right, but is there anyway to position something at the bottom of a box?


Solution

  • You can use absolute positioning. Absolute positions relative to its first positioned ancestor. If there is none it defaults to the document. So I gave it a parent with relative.

    http://jsfiddle.net/DSpkv/

    #parent { position: relative }
    #foo { position: absolute; bottom: 0; right: 0; }
    
    <div id="parent">
      <div id="foo"></div>
    </div>