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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:32:24+00:00 2026-06-04T20:32:24+00:00

I am currently creating a mahjong game. The game is as good as complete.

  • 0

I am currently creating a mahjong game. The game is as good as complete. Everything worked fine until I decided to put the game in a div (div id="holder") to make sure it will be centered in the browser window.

What happens?

Step 1:
Resize you browser window so it matches the games size (so no white border on the left or on the right. Note: The problem also applies when adding more space to the top, but in this demo it is not possible to adjust this.

Step 2:
Click: Click to Start, the game will start and then click any HINT button. You will see a nr appearing above the button you’ve just clicked, it moves up, and disappears. This nr is positioned correct and should always appear in the middle just above the HINT button you’ve clicked.

Step 3:
Now resize your browser window, give the game (let’s say) 2cm of white space on the left and on the right.

Step 4:
Now click another HINT button. Notice the nr is appearing, but NOT in the middle and above the HINT button anymore, but 2cm to the right.

So what is happening? My guess is that the offset of the div (div class="score"), which contains the nr, includes the white space to its offset (or something like this).

This is something I obviously don’t want! But I have no clue of how to fix this…

Some code snippets:

The DIV’s CSS:

#holder {
    width: 940px; 
    margin: auto auto;
}
.score {
    display: none;
    pointer-events: none;
    position: absolute;
    font-size: 1em;
    text-align: center;
    color:#FFF;
    z-index: 1;
}

The JS-part (using jQuery):

var offset = $(this).hide(500).offset();
var penalty = Math.round(score * -0.10);  //calculates a score penalty
score += penalty; //this is the result
$('.sc').text(score); //this is needed elsewhere in the script
$('.score') //start of showing the div and it's animation
      .show()
      .text(penalty)
      .css({
          top: offset.top - $('.score').height() - 90,
          left: offset.left,
          width:'3.5em'
      })
      .stop()
      .delay(100)  
      .animate({top: offset.top - $('.score').height() - 140},700)
      .hide(0); 
 ...some more code here, not relevant to this

If more code is needed, please let me know, but I think this is sufficient. Hope this problem can be solved!

Kind regards

  • 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-04T20:32:25+00:00Added an answer on June 4, 2026 at 8:32 pm

    I think I have found it. IN my CSS I have another div:

    #s0 {
        position: relative;
        float: left; 
        height: 570px;
        width: 760px;
        background: #222 url('images/bg.png');
    }
    

    Removing: position: relative; seems to fix it. Will do some more testing. All thanks for you suggestions!

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

Sidebar

Related Questions

Im currently creating a tile-based game for android. Using java via dalvik JVM. im
I'm currently creating my first Chrome extension, so far so good. It's just a
I am currently creating a spelling game which is currently drag and drop .
I am currently creating a spelling game where you drag and drop letters onto
I am currently creating a game that allows the user to click on numerous
im currently creating a graph for an app, using coreplot and have a problem
I am currently creating an application for compiling multiple java projects in one go
I'm currently creating a payment SDK for android, as such I want to send
I'm currently creating an iPhone app (Xcode 4.3.1, IOS 5) that could use Bluetooth
I'm currently creating a iOS 5 iPad app where there will be heavy network

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.