Results 1 to 4 of 4

Thread: div centered

  1. #1
    Join Date
    Jul 2008
    Posts
    81
    Thanks
    38
    Thanked 2 Times in 2 Posts

    Default div centered

    Hi,

    I have a div with image inside. On every page there is a different image in it, with different size. I want this div to be placed horizontally and vertically in the center of the screen, how can I do it?

  2. #2
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    the easiest way is using
    Code:
    <div align="center">
    <div>
    (this div is centered)
    </div>
    </div>
    or you can read this:
    css/center
    _____________________

    David Demetrius // davejob
    _____________________

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by davelf View Post
    the easiest way is using
    Code:
    <div align="center">
    <div>
    (this div is centered)
    </div>
    </div>
    or you can read this:
    css/center
    Terribly wrong!!! (X)HTML should never be used for presentational purposes.
    Review the following

    Code:
    div {
    	position: absolute;
    	top: 50%;
    	left: 50%;
    	width: 300px;
    	height: 300px;
    	margin: -150px 0 0 -150px;
    }
    img {border:none}

    HTML Code:
    <div><img src="/folder/file.jpg" alt="textual representation of the content of the image"></div>

  4. #4
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    ups, sorry.
    _____________________

    David Demetrius // davejob
    _____________________

Bookmarks

Posting Permissions

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