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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:13:54+00:00 2026-06-11T15:13:54+00:00

I have been working on a simple tool tip (see fiddle below), but am

  • 0

I have been working on a simple tool tip (see fiddle below), but am having some positioning problems. I would like the tip to appear centered and above the link that is clicked. At the moment the top left corner is positioned at the mouse click. I tried to offset this position by half of the tooltip but to no success.

http://jsfiddle.net/Ricco/CBf4C/

  • 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-11T15:13:55+00:00Added an answer on June 11, 2026 at 3:13 pm

    Check out the changes at http://jsfiddle.net/CBf4C/3/

    You need to get the position of the clicked element (use .position()), get the dimensions of the tooltip with .outerWidth() and .outerHeight() and then calculate based on these..

    the actual code is

    $('a[title]').click(function(e) {
    
        //fadetooltip and display information
        $('body').append('<div class="tooltip"><div class="tipBody"></div></div>');
        tip = $(this).attr('title');
        var tooltip = $('.tooltip'); // store a reference to the tooltip to use it later
        tooltip.fadeTo(300, 0.9).children('.tipBody').html( tip );
    
    
        // calculate position of tooltip
        var el = $(this),
            pos = el.position(), // get position of clicked element
            w = el.outerWidth(), // get width of clicked element, to find its center
            newtop = pos.top - tooltip.outerHeight() , // calculate top position of tooltip
            newleft = pos.left + (w/2) - (tooltip.outerWidth()/2); // calculate left position of tooltip
    
        //set position
        $('.tooltip').css('left', newleft )  ;
        $('.tooltip').css('top',  newtop );
    
        hideTip = false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been using a simple CSS only tooltip. Working Example css: .tip { position:relative;
I have been working with simple linq2sql statements for a bit but am new
I have been working for several of hours on an simple animation but nothing
I have been working on a project on and off, but I haven't touched
I have a simple CSS help popup that's been working well for me in
I have been working on a simple text editor in Cocoa/Objective-C for a practice
I am new to Silverlight and have been working with Simple MVVM to create
I have been working on a simple app to play a random sound byte
I have been working on my Ruby. When trying to execute this simple example
So lately I have been working on writing a simple compiler to better understand

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.