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 8033873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:50:15+00:00 2026-06-05T01:50:15+00:00

I can’t center vertically popup_interstitial_table that contains an ads type container. The fiddle it

  • 0

I can’t center vertically popup_interstitial_table that contains an ads type container.

The fiddle it is autoexplained: http://jsfiddle.net/NomikOS/D8LLM/

jQuery solutions are welcome too.

HTML:

<div id="popup_interstitial">
    <div id="parent">
        <div id="popup_interstitial_pro_head_text">
            Headline text 
        </div>
        <div id="child">
            <div id="popup_interstitial_table">
                <div id="popup_interstitial_row2">
                    <div id="popup_interstitial_title"><?php echo $title; ?></div>
                    <img id="popup_interstitial_image" src="<?php echo $image; ?>">
                    <div id="popup_interstitial_description"><?php echo $description; ?></div>
                </div>
            </div>
        </div>
    </div>
</div>

The related CSS code is:

#popup_interstitial_pro_head_text{
    color:#FFF; 
    font-size: 2em;
    font-weight: normal;
    text-shadow: 0.05em 0.05em #666;
    background-color: #A5CF4C;
    width: 100%;
    padding-left: 1%;
    padding-top: 0.8%;
    padding-bottom: 0.8%;
    border-top-width: thin;
    border-top-style: solid;
    border-top-color: #648323;
    border-bottom-width: thin;
    border-bottom-style: solid;
    border-bottom-color: #759928;
    margin-bottom: 2%;
    -webkit-box-shadow: 1px 1px 8px #333333;
    -moz-box-shadow: 1px 1px 8px #333333;
    khtml-box-shadow: 1px 1px 8px #333333;
    filter: shadow(color=#333333, direction=135, strength=0);
}
#popup_interstitial {
    display: none;
    width: 100%;
    height: 100%;
    position: fixed;
    background-color:#FFFFFF;
    color:#111;
    z-index:9999;
    top:0;
    left:0;
}
#popup_interstitial_table {
    width: 50%;
    margin: 0 auto 0 auto;
    background-color:#E7E7E7;
    padding: 1em 2.2em;
    font: 0.85em "Trebuchet MS", Arial, Helvetica, sans-serif;
    margin-top: 5%;
    vertical-align: center;

}
#popup_interstitial_title{
    color:#FFF; 
    font-size: 1.5em;
    font-weight: bold;
    padding: 0 0 0 0.3em;
    border-bottom-width: thin;
    border-bottom-style: solid;
    border-bottom-color: #777;
    background-color: #888; 
    border-radius: 0.3em;
}
#popup_interstitial_description{
    padding-top: 1.7em;
    padding-bottom: 1.2em;
    border-bottom-width: thin;
    border-bottom-style: solid;
    border-bottom-color: #ccc;
    line-height:1.5em;
}

#popup_interstitial_image{
    vertical-align: baseline;
    margin: 25px 20px 3px 0;
    -webkit-box-shadow: 1px 1px 8px #333333;
    -moz-box-shadow: 1px 1px 8px #333333;
    khtml-box-shadow: 1px 1px 8px #333333;
    filter: shadow(color=#333333, direction=135, strength=0);
    padding: 4px;
    margin-left: 6px;
    float: left;
}

This is the most important:

#parent {position: relative;}
#child {
    padding: 0% 0;
    margin: 0 auto; 
}
  • 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-05T01:50:16+00:00Added an answer on June 5, 2026 at 1:50 am

    To your current structure, you have two solutions to make it work:

    1) CSS

    Wrap the elements with a div and use this trick:

    See this working Fiddle Example! (If you move the frame up and down, you see that the target stays vertically centered.)

    #childWrap {                  // the new element, the mentioned wrapper
      display: table;
      width: 100%;
      height: 100%;
    }
    #child {                      // your element that needs to be restyled
      display: table-cell;
      width: 100%;
      height: 100%;
      vertical-align: middle;
    }
    #popup_interstitial_table {   // the element vertically aligned
      width: 50%;
      margin: -48px auto 0 auto;
    }
    

    What is done here is to set the wrapper element to display as a table, occupying the entire width and height of its parent (#parent).

    Then, we can set the #child to display as a table-cell, and set its contents to vertical align at the middle.

    Now the trick, since the #parent also contains another element that you need to stay put, but have its height removed from the “center” calculations for the #popup_interstitial_table, we need to pull the #popup_interstitial_table with a margin-top:-60px to fix its position. The negative margin is the height that the #popup_interstitial_pro_head_text occupies.

    Important note:

    Since you have this structure, in order to pass to the browser the fix, your #popup_interstitial_pro_head_text needs to work with a single unit, I’ve chosen px for the example.

    You had a mixture of % and em on several declarations!


    On a side note:

    Vertical-align: center;

    You use:

    vertical-align: middle;

    See this link for further information!


    2) JQUERY

    With jQuery, you can collect the space being occupied by the #popup_interstitial_table and calculate the necessary top and left fix values to keep it vertically centered:

    See this working Fiddle Example! (If you move the frame up and down, you see that the target stays vertically centered.)

    JQUERY

    function center() {
      var $target = $('#popup_interstitial_table'),
          $header = $('#popup_interstitial_pro_head_text'),
          fixTop  = ($target.outerHeight(true)/2)-($header.outerHeight(true)/2),
          fixLeft = $target.outerWidth(true)/2;
    
      $target.css({
        "margin-top": "-" + fixTop + "px",
        "margin-left" : "-" + fixLeft + "px"
      });
    }
    
    $(document).ready(function() {
      center();
    });
    

    CSS

    To prevent massive script calculations, the CSS should get fixed to this:

    #parent {
      position: relative;
      height: 100%;        // this was added
    }
    #child {
      padding: 0% 0;
      height: 100%;        // this was added
    }
    #popup_interstitial_table {
      width: 50%;
      margin: 0 auto 0 auto;
      background-color:#E7E7E7;
      padding: 1em 2.2em;
      font: 0.85em "Trebuchet MS", Arial, Helvetica, sans-serif;
      position: absolute;  // this was added
      top: 50%;            // this was added
      left: 50%;           // this was added
    }
    

    So, a repeat that without changing your current structure, this are the two solutions I could think of to center your element!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can a LINQ enabled app run on a machine that only has the .NET
Can we change the color of the divider? Apple documentations says, that we can
Can anybody tell me that what is suitable Xcode version for 10.6.8(snow leopard)?Does Xcode
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can I register a .Net COM class with the SingleUse -flag? The reason I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can anyone help me with an excel formula that groups related rows and creates
Can somebody point me to a resource that explains how to go about having
can you recommend some good ASP.NET tutorials or a good book? Should I jump
Can we say that a truncated md5 hash is still uniformly distributed? To avoid

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.