Results 1 to 2 of 2

Thread: Image at the Bottom

  1. #1
    Join Date
    Sep 2005
    Posts
    170

    Image at the Bottom

    Hello.

    I have a div that is the main content box.

    Inside this div i have 2 images in divs.

    Image and div 1 must sit at the top of the content box - No problems here.

    Image and div 2 must always sit at the bottom of the content box - heres the problem.

    I cannot get the image to stay at the bottom of the div regardless of the size of the content box.

    I have tryed postion abolsute with bottom set to 0 but this sends it to the bottom of the page and not the div.

    In the same way if i use margin-top: 100% it sends it to the bottom of the page as does padding.

    Solutions?

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    The position: absolute will take its position from the page or screen window normally, which is why your bottom image is at the bottom of the page.

    However, if the containing div has position: relative, anything that is position: absolute inside it will take its position from the div dimensions and not from the page/screen dimensions.

    This works as image 1 is at the top of the div and image 2 is at the bottom (I've just tested it):-

    <div style="position: relative; width: 400px; height: 500px;
    border: 1px solid black;">

    <img style="position: absolute; top: 0; left: 200px;"
    src="image1.jpg" alt="image 1">

    <img style="position: absolute; bottom: 0; left: 300px;"
    src="image2.jpg" alt="image 2">

    </div>

    See
    http://www.wickham43.supanet.com/tutorial/divboxes.html
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Similar Threads

  1. image at center bottom of a div
    By enfieldman in forum General Questions
    Replies: 1
    Last Post: 22 Oct 2007, 11:21 AM
  2. aligning image to bottom of div causing issues
    By archanix in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 23 Aug 2005, 11:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •