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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:16+00:00 2026-05-23T15:51:16+00:00

This is strange. I’m trying to have a fixed-width div next to a right-floated

  • 0

This is strange. I’m trying to have a fixed-width div next to a right-floated div, and I don’t want to reorder the divs (because this is distributed theme). So I’m playing with negative margin-right on the fixed div, and I get what seems to me strange: if it’s -4px or less, then the float moves to the side; otherwise, it stays below.

Play with the live demo with code at jsbin, which has this:

<style>
  .container {
    width: 200px;
    height: 200px;
  }
  .box {
    width: 100px;
    height: 100px;
  }
  .one {
    margin-right: -4px; /* If <= -4, .two box shifts up */
    display: inline-block;
  }
  .two {
    float: right;
  }
</style>
  <div class="container">
    <div class="box one"></div>
    <div class="box two"></div>
  </div>

Can someone explain the mystery? What’s special about the number -4 in this case?

  • 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-23T15:51:16+00:00Added an answer on May 23, 2026 at 3:51 pm

    4px just happens to be the width of a “space” at that font-size.

    If you change the font-size of #container to say, 32px, it breaks.

    Sensible ways to fix this include:

    • Remove margin-right: -4px and then remove the whitespace between the divs in the HTML.
    • Don’t use display: inline-block. Instead, float: left the left div, and float: right the right div.
      • If you’re worried about it breaking when you don’t have a fixed height on the container, then you must clear the floats. Use overflow: hidden on the container, or use clearfix.
      • With overflow: hidden (use this unless you have specific problems)
      • With clearfix
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying my hand with jQuery. I have this strange situation that i wish to
I have this strange call stack and I am stumped to understand why. It
I have this strange issue with my web app. You see, I'm using jQuery
Trying to install pear package and keep getting this strange error. Can you shed
I've got this strange problem using py-amqp and the Flopsy module. I have written
I often find this strange CDATA tag in XML files: <![CDATA[some stuff]]> I have
I have this strange issue with some third party DLL's. The third party provider
There is this strange situation I'm fighting on. I have 3 pages, les call
I have this strange scenario. I have a table having multiple rows (each generated
I have this strange problem. I have this script: echo $comment_content = $_POST['comment_content']; echo

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.