Is there any way to put images at center vertically inside <div> tag

3 replies
Hi, I am unable to crop images to fit exactly div. So, I am looking for any css method to place images vertically at center. Is there any way to put image at center of div tag

Thanks
#<div> #center #images #inside #put #tag #vertically
  • Profile picture of the author Michael71
    Google: css center image in div
    Signature

    HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
    ---
    Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

    {{ DiscussionBoard.errors[8096738].message }}
  • Profile picture of the author lem0n
    Originally Posted by apnavarun View Post

    Hi, I am unable to crop images to fit exactly div. So, I am looking for any css method to place images vertically at center. Is there any way to put image at center of div tag

    Thanks
    Did you even try to look for the answer yourself?
    Let me google that for you

    Try the above link, it uses a brand new technology which I'm not supposed to show yet but w/e...

    But seriously press the link, wait till the end and see the answers. There are many ways to achieve what you want and depending on your case one choice might be better than the other.
    {{ DiscussionBoard.errors[8096739].message }}
  • Profile picture of the author FirstSocialApps
    Sure, lol :

    <div style="padding:20px;"
    <img src="foo">
    </div>

    Image is no centered vertically in the div with 20px on top and on bottom.

    Somehow what I think your looking for is: position:absolute; top: [1/2 the main divs height] , margin-top: -[1/2 the image height]
    {{ DiscussionBoard.errors[8096855].message }}

Trending Topics