Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:13:45+00:00 2026-06-18T04:13:45+00:00

I was wondering in someone knows how to vertically center a child div inside

  • 0

I was wondering in someone knows how to vertically center a child div inside a parent div without knowing the parent divs height?

I have a pinterest style gallery page (images) and on hover I show a div over the top of the images with information about the image. Know because each image could have a different height, I don’t know how to center the child content to the middle of the parent div.

I am using jQuery Masonary plugin to create the layout.

Currently I have an outer div containing the image. An inner div with a background colour of white (or whatever) positioned 0,0 and width and height 100%. This all works great and I have been able to center horizontally by simply using text-align: center;

Many thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:13:46+00:00Added an answer on June 18, 2026 at 4:13 am

    This should work to set it centered both ways. Did not test yet:

    var ParentW = $("parent-id").width();
    var ParentH = $("parent-id").height();
    var ChildW = $("child-id").width();
    var ChildH = $("child-id").height();
    var PosW = (ParentW - ChildW)/2;
    var PosH = (ParentH - ChildH)/3;
    $("child-id").css({"top":PosH, "left": PosW });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering if someone could help me. I have next to no knowledge with Ajax,
I was wondering if someone knows a way to completely remove the push notification
I'm wondering if someone knows how to store an array into a user session?
I was wondering if someone knows what controls the showing of previous form field
I was wondering if someone knows the exact measurements of the new Windows Phone
I'm wondering if someone knows/has a C macro to compute a static Unix time
I was wondering if someone knows what I need to do to make Zend
I am running the script below. I was wondering if someone knows how to
I was wondering if someone knows the best (or most secure) way to allow
Just wondering if someone knows what is wrong with my javascript math script below:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.