jquery expand and align

Posted on 2012-03-31
Last Modified: 2012-04-08
Hello Experts,

I really need a help from an expert here!

I have a photo. On that photo i placed a circles with numbers using css absolute positions.
When the user mouse-over a circle the circle expands around 1.5 times (e.g. the initial size of a circle is 16px on 16px and it grows to 24px on 24px.

The problem.....

The number on the circles are horizontally center-aligned using the css text-align:center.
When the circle expands the numbers should also be vertically align.

I tried varied options using padding-top and or increasing line-height but nothing seem to work smoothly.

Here is just a part of the script i am using to expand the circle. If you have a good idea i would be thankful!

  var $position;
    $position = $(this).position();

       width: 24,
       height: 24,
       top: ($ - (8/2)), left: ($position.left -(8/2))}, 100);
}).mouseleave(function() {

        width: 16,
       height: 16,
       top: $, left: $position.left}, 100);

Open in new window

Question by:Refael
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 38

Accepted Solution

Tom Beck earned 500 total points
ID: 37792310
You were on the right track with line-height, however, as the circle expands, you must also increase the line-height then set it back to 16 on mouseleave.

var $position;
        $position = $(this).position();

            width: 24,
            height: 24,
            top: ($ - (8/2)), left: ($position.left -(8/2)), 'line-height':'24px'}, 100);
    }).mouseleave(function() {

            width: 16,
            height: 16,
            top: $, left: $position.left, 'line-height':'16px'}, 100);

Author Closing Comment

ID: 37821871
Thank you!

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can anyone help me find this preloader? 51 67
Slush on text 2 25
Jquery Calculation 3 40
Time Picker 3 22
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question