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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:17+00:00 2026-05-25T20:21:17+00:00

I am trying to create a purely HTML and CSS-based layout that presents the

  • 0

I am trying to create a purely HTML and CSS-based layout that presents the main content of a page on the left (which expands to the full width of the page, minus the box) and a smaller box on the right, say for navigation or information of some sort. Here is an example of the code that is causing the problem, with the problems described therein:

<!DOCTYPE HTML>

<html lang="en" dir="ltr">

<head>
 <title>Floating Div Madness upon Window Resize</title>
 <style>
  * {margin:0; padding:0}
  body {margin:20px; font-size:0px; color:#000000}
  div.page {margin-right:120px; background-color:#AAAAFF; float:left}
  div.wide {width:300px; background-color:#AAFFAA}
  div.box  {width:100px; margin-left:-100px; background-color:#FFAAAA; float:left}
  h1 {font-size:x-large}
  p {padding-bottom:5px; font-size:small}
 </style>
</head>

<body>

 <div class="page">
  <h1>MAIN PAGE</h1>
  <p>This is the main portion of the page (light blue). It is currently floated left with a right margin of 120px, to account for the box (light red) as well as the white space between it and the box (light red). All may look well on the surface, but...</p>
  <p>Resize the window in Firefox (I tested both 3.5 and 4) and the white margin of the body can be cut off, not only on the right side, but on the bottom of the page, too.</p>
  <p>Remove enough text and this div will shrink to fit it, no longer taking up the entire width of the page (minus the box).</p>
   <div class="wide">
    <p>If I nest another, non-floating div with a fixed width (light green), something even stranger happens when I resize the window, this time in Internet Explorer 6 (maybe in other versions, too): The text in the page div (light blue) is squished, I think by the margin of the box (light red). The fixed width div (light green) is unaffected by this.</p>
   </div>
 </div>

 <div class="box">
  <h1>BOX</h1>
  <p>(this could be navigation, or anything else)</p>
 </div>

</body>

</html>

I would like to keep the box (light red) later in the code for semantic reasons, but this is optional. Here are some of the more successful things I’ve already tried, and why they don’t seem to work:

  1. Absolute positioning: This appears just as nicely as my own code when the browsers are not resized. It does address the disappearing body margin in Firefox to some degree. However, when the window size gets small enough, the box (light red) will go over or under the main page div (light blue), depending on the which z-index I have higher or lower.

  2. Floating only the box: This involves changing the HTML and placing the box (light red) before the rest of the content in the code. This automatically expands the main page div (light blue), something I haven’t found a way to do (without a given amount of content) using the float method. However, the margins of the body are still removed in Firefox, the text still squishes in IE, and box (light red) will still go over or under (again depending on the z-index) the main page div (light blue) when the window gets small enough.

  3. Assigning min-width to everything: This was very successful in stopping the IE problem, but requires some CSS work on a page that is any more complex than this and which will support different media types. And, it still doesn’t address the body margin in Firefox or give me a way to expand the main page div (light blue) without content, since it is still floating.

  4. Changing the body margin to a border: This doesn’t solve the Firefox problem either; whether it is a border or a margin, it gets chopped off on the right and bottom of the page when I use floats.

  5. Add the margin to the box: This doesn’t work for Firefox, either. I can get a bottom margin on the main page content (light blue) to stay in place (this is something that seems especially curious to me), but a right margin on the box (light red) still gets cut.

Any help would be greatly appreciated, as I cannot find any sites or posts answering these problems, much less describing that these problems exist; I’ve certainly put in a large number of hours looking for and testing solutions!

  • 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-25T20:21:17+00:00Added an answer on May 25, 2026 at 8:21 pm

    Good day to you dear sir, you seem to have trouble building layouts.

    As I understood it you want a 2 column layout. Left column auto expands to the width of w/e it is in minus the right columns width minus 20 pixes for margin. Right column is a fixed width and will contain a menu or assorted html structures…

    In the left column you have text and among other things, a fixed width box, the fixed width box in this column should always stay inside it. This means we want a minimum width wich is the fixed width box width + 20 px margin + the right column width.

    I did that by making a container arround all of the content, applying min width to that and making a dummy container to solve the min width problem in IE6.

    Here is a working example of how this looks: http://jsfiddle.net/uXyPu/

    I don’t have a version of IE6 or firefox 3.5 running to test it but I am fairly confident this will work.

    As a side note, you used a margin on the body tag, don’t do it. As a base rule keep your body fully expanded, at most apply a padding. Aside this, avoiding margins is a good way to prevent a merriad of problems in IE6 while still keeping your layout compatible with modern browsers. And don’t use padding / margin at all on floated elements…

    The gentleman in the first comment on your question was right about avoiding ie6 altogether, I hope you asked big bux to do this project so the company might actually start thinking about their abuse of ie6…

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

Sidebar

Related Questions

I am trying create a WCF service that leverages the WPF MediaPlayer on the
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
I'm trying create a box in my Django app that displays text (and possibly
I'm trying create this function such that if any key besides any of the
I am trying create a data.frame from which to create a graph. I have
I'm currently trying create a service that will return results of a OLAP cube
I am trying create a new css for shaping my detailsview. But i couldn't
I am trying create a new frame in wxPython that is a child of

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.