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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:42:04+00:00 2026-05-26T14:42:04+00:00

I’m trying to make an iPad-like popover div as an exercise, but I can’t

  • 0

I’m trying to make an iPad-like popover div as an exercise, but I can’t find out how to vertically center the popover div, having an unspecified content width/height.

http://jsfiddle.net/mbYyR/5/

I want the triangle to point to the position defined by #popover-wrapper’s top/bottom right/left values, but top: -50% does not work.

Thanks for your help 🙂

  • 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-05-26T14:42:05+00:00Added an answer on May 26, 2026 at 2:42 pm

    If you do not want to use javascript, then centering it vertically is not possible (as previously stated by others). However, if your goal is to simply have a nice pop-up that allows some flexible width/height, I recommend the following pure CSS solution. Some explanation follows each section for what I did and why I did it.

    OPTION #1 HTML (my preferred)

    <div id="popover-wrapper">
        <div id="popover-direction-setter">
            <div id="actual-popover-div">
                <div id="content-with-unknown-height">
                    Content Content with unknown dimensions. Tip should point to the blue dot
                    Content with unknown dimensions. Tip should point to the blue dot
                    Content with unknown dimensions. Tip should point to the blue dot
                </div>   
            </div> 
        </div>
    </div>
    <div id="target-blue-dot"></div>
    

    The triangle div is gone, because I am going to use an :after pseudo class to apply it since it is purely presentational.

    OPTION #1 CSS (note the #triangle-tip code was replaced with #popover-direction-setter:after)

    #popover-direction-setter {
        position: absolute;
        right: 20px; /* grow left */
        top:   0px;
        background: #EEE; /* for debugging */
        width: 160px; /*left position of wrapper - 40px for right position of this and triangle tip border size */
    }
    
    #actual-popover-div {
        position: absolute;
        right: 0px;
        top: -.5em;
        margin-top: -25px; /* border-radius + half the height of the triangle */
        padding: 0.5em;
        background: black;
        color: white;
        border-radius: 15px;
        min-height: 50px; /* 2 * border radius + half the height of the triangle */
    }
    
    #popover-direction-setter:after {
        content: '';
        position: absolute;
        width:  0;
        height: 0;
        top:           50%;
        margin-top:   -20px;
        border-top:    20px solid transparent;
        border-bottom: 20px solid transparent;
        border-left:   20px solid black;
        right:        -20px;
    }
    

    Do not be alarmed by the #popover-direction-setter having width set. I presume you know the left position (since you use it), so this width can be pre-calculated and makes a maximum width that the pop up will be so that it does not end up flowing off the left side of the browser window. I would think that would be a good thing.

    The min-height is set on #actual-popover-div so that if content is minimal, it looks good with the triangle.

    The top position of #actual-popover-div is offsetting your em sizing on the padding. The margin-top on that element is just bumping up enough to make the arrow sit nicely in the upper corner, and be centered when the min-height takes effect.

    OPTION #2 HTML (keeps triangle div but repositions it)

    <div id="popover-wrapper">
        <div id="popover-direction-setter">
            <div id="actual-popover-div">
                <div id="content-with-unknown-height">
                    Content Content with unknown dimensions. Tip should point to the blue dot
                    Content with unknown dimensions. Tip should point to the blue dot
                    Content with unknown dimensions. Tip should point to the blue dot
                </div>   
            </div> 
            <div id="triangle-tip"></div>
        </div>
    </div>
    <div id="target-blue-dot"></div>
    

    OPTION #2 CSS remains as you originally had the triangle div and eliminates my :after pseudoclass code.

    I know this does not meet your challenge requirements fully. Again, I agree with others that there is no way currently to position an element centered vertically with an undetermined height. However, if nothing else, others may find my solution good for them.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.