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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:36:04+00:00 2026-06-11T12:36:04+00:00

I have horizontally stacked divs using the following code below: .basic { width:100px; position:relative;

  • 0

I have horizontally stacked divs using the following code below:

.basic {
    width:100px;
    position:relative;
    display:inline-block;
    border: 1px solid red;
    text-align:center;
    margin:0;
    padding:0;
}

#container {
    white-space: nowrap;
    border: 1px solid black;
    width:300px;
    overflow:auto;
}

The ‘container’ has white-space:nowrap for stacking it’s children horizontally. However, the horizontal children have spaces to their right. Here’s a fiddle showing the demo. Inspecting box layout there doesn’t seem to be any margin/padding. But just some mysterious ‘dark matter’ pushing it out 😛

The queer thing is that the same code is used at different places in my application but this anomaly shows up in one place as shown in the image below:

enter image description here

Don’t worry about the garbled text on the top. I haven’t rotated the div 90 degrees CCW as yet 🙂
However, pay attention to the bottom part of the image. The textbox divs are stuck to each other whereas the ones on the top aren’t. They use the same CSS as above, but differ in structure. The top Div has two floats which are cleared by the div with the arrow towards the bottom. So no ‘uncleared’ floats there. Rather than posting the entire HTML/CSS I recreated the problem in the fiddle.

What I fail to understand is that even after having 0 margin/padding and display:inline-block for the child divs why is there still some space? I’m sure this has been asked quite a few times here but why would this happen once and not in another place? Besides, how best to ‘fix it’??

  • 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-11T12:36:05+00:00Added an answer on June 11, 2026 at 12:36 pm

    display: inline-block places a margin to the right if there exists a whitespace between the current and the next element. This space is calculated as a product of 4px and the current font-size in ems. Notice the difference between the first and second rows in this fiddle: http://jsfiddle.net/MkasM/

    In your case, this can be controlled simply by setting margin-right: -4px since you haven’t changed the font-size.

    More here: http://css-tricks.com/fighting-the-space-between-inline-block-elements/

    Also, it is good practice to give your elements ‘box-sizing: border-box’ if you haven’t already. It will contain the ‘padding’ and border-widths within the blocks so it wont interfere with the layout.
    To read: http://paulirish.com/2012/box-sizing-border-box-ftw/

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

Sidebar

Related Questions

So basically I have 3 inline-block divs that are stacked horizontally as such: div1
I have 2 divs that positioned horizontally ( float:left; width:50%; ). But i want
I currently have a bunch of inline-block div s stacked up horizontally. When the
I want to have 5 divs horizontally next to each other spanning the width
I have two quite narrow (width:400 px) divs that should be stacked vertically if
I have a ListView where I would like to display things horizontally. That works
I am trying to make my subnav list display horizontally rather than stacked. I
I have a horizontally scrolling UIScrollView and I want to display potentially thousands of
I have two horizontally scrolling UIScrollViews stacked vertically on top of each other within
I have stumbled accross the following snippet, for creating horizontal bar chart using matplotlib:

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.