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

  • Home
  • SEARCH
  • 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 5940093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:55:14+00:00 2026-05-22T15:55:14+00:00

I have a rather interesting problem, and wondered if it could be done purely

  • 0

I have a rather interesting problem, and wondered if it could be done purely in CSS. I know you can use webkit moz transforms, or javascript, but is there another simple CSS cross browser solution to this?

I have a box with a class container say

.container
{
 position: absolute;
 border: black 1px solid;
 top: 100px;
 left:100px;
 width: 10px;
 height: 10px;
}

Now what I want to do is on mouseover (CSS hover) is enlarge the box to 30px by 30px around a central point somewhere in the approximate centre of the 10×10 box, returning to the original container when I mouse out. Something along the lines of:

.container:hover
{
 width: 30px;
 height: 30px;
 top: 90px;
 left:90px;
}

Now the difficulty comes in that the top and Left positions are set into the HTML being sent from the database, and therefore do not appear in the CSS file.

The option is that I dynamically generate the CSS file from the DB data, and effectively create a class for every object (I really think this is a bad idea) or I use Javascript to manage some calculation onmouseover and onmouseout but this strikes me as being not very elegant. It’s what I’m doing now. eeeugh.

So come on guys is there a better CSS solution?

  • 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-22T15:55:14+00:00Added an answer on May 22, 2026 at 3:55 pm

    If it just the top/left then you can ignore those and use the margins to move them around (provided that you know the dimensions)

    .container:hover
    {
     width: 30px;
     height: 30px;
     margin-left:-10px;
     margin-top:-10px;
    }
    

    demo http://jsfiddle.net/gaby/CuuNW/


    The important calculation is that the margin need to match the half of the size increase that occurs on hover.

    so, 30 pixel final size minus 10 pixel initial size is 20 pixels. You need to offset (using margins) 20/2 = 10 pixels.

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

Sidebar

Related Questions

I have a rather interesting problem. I have a parent page that will create
We have a rather simple site (minimal JS) with plain html and CSS. It
I have a rather interesting issue with SVG animation. I am animating along a
I have a bit of an interesting problem where I need to create an
I have met an interesting problem while implementing the Observer pattern with C++ and
I thought it would be interesting if I could use the new MVC Razor
I have an interesting project in mind, and I have a question. You can
I have rather large input XML files that must be converted to a given
I have a rather large file (150 million lines of 10 chars). I need
I have a rather classic UI situation - two ListBoxes named SelectedItems and AvailableItems

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.