Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    valign middle for image in div

    .thumbimage{
    width:125px;
    height:180px;
    border: thin solid #999999;


    }

    above is my css

    this is a div around an image

    how can I make it that any image in this div should be vertical aligned centered?

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,304
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by esthera View Post
    how can I make it that any image in this div should be vertical aligned centered?
    Code:
    .thumbnail { display: table-cell; vertical-align: middle; } /* CSS2+ */
    .thumbnail img { margin-top: expression((this.parentNode.clientHeight - this.clientHeight) / 2 + "px"); } /* IE */
    Note that the Internet Explorer method will fail when JScript is disabled.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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