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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:03:43+00:00 2026-06-03T11:03:43+00:00

So, I have this small bit of code that generates rows and columns of

  • 0

So, I have this small bit of code that generates rows and columns of boxes with space in-between them.

It seems to work fine; however when I set the height and width of the boxes to 32 pixels and the space in-between them to 8 pixels, there are gaps that start to appear where boxes should be.

If I use just about any other numbers they work, but of course I had my mind set on 32 and 8.

I am wondering if it’s the method in which I am looping through creating the boxes or if there’s some underlying math going on that I don’t understand.

Here’s a jsFiddle set up with the code in question:

http://jsfiddle.net/dondon/zMnuK/

If you modify the ‘spacing’ in the JS section to say 7 or 9, the gaps vanish. What is it about 8 (or 4) that cause the gaps to appear?

Any input is appreciated! 🙂

  • 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-03T11:03:48+00:00Added an answer on June 3, 2026 at 11:03 am

    It has to do with multiple boxes having the same id and the css being set on both of them such that they end up in the exact same position. For example, the third box created has x position (x is vertical with your looping order) 88px, and y position 8px. Then much later in the third row a box with y = 88px, and x = 8px. is reached, so 'box' + x + y; is identical for both these boxes. You can’t have more than one element with the same id, so anything can happen after that.

    The simple solution is to change:

    var boxid = "box"+x+y;
    

    To:

    var boxid = "box"+x+'_'+y;
    

    Updated JSFiddle

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

Sidebar

Related Questions

I have this small piece of code that basically takes a list and runs
Work on this small test application to learn threading/locking. I have the following code,
I have a small bit of code that gets my images from smugmug. My
I have a small bit of code that runs in an applet that contains
I have a small piece of code that requires to read 4-bit values bitpacked
I have this small snippet to change a bit of html when a user
I have this small class called City that simply holds some information about a
I have this small PHP script that takes a POST variable and writes it
I have a bit of JavaScript code that is specified in a configuration file
Strange Question i guess but i have this bit of code in my page...

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.