Solved

How to prevent floated divs from wrapping in IE6 and above and mozilla.

Posted on 2009-07-10
2
406 Views
Last Modified: 2013-11-19
Hi

Could someone help me stop the 'divCell' in code below from wrapping when the browser is narrowed?  I need the solution to work in IE6 and above and mozilla firefox. I have a minimum width set but even the slightest narrowing of the window causes the right div to wrap below the left one.

The reason why this happens is because of this line..
.divCell
{
    width:50%;

If I set the width to say 49.9% the div does not wrap but I really would like everything to be pixel perfect.

Your help would be greatly appreciated.

Cheers
<div id="divTable">

            <div class="divRow">

                <div class="divCell">

                asdfasdf

                </div>

                

                <div class="divCell">

                asdfasdf

                </div>

            </div>

        

        </div>

#divTable

{

    width:100%;
 

    background-color:Gray;

}

.divRow

{

    width:100%;
 

    background-color:Lime;
 

}

.divCell

{

    width:50%;

    float:left;

    background-color:Green;

}

Open in new window

0
Comment
Question by:jazz__man
2 Comments
 
LVL 30

Accepted Solution

by:
renazonse earned 300 total points
Comment Utility
IE is a pain and renders the margins a bit different from other browsers. It doesn't break apart for me in FF but you can add this to your IE.css or keep it uniform for all browsers:

.divCell
{
    width:50%;
    float:left;
    background-color:Green;
    margin-right:-1px; <--ADD THAT
}

It's not as bad as changing the percentage since it will always only be 2px off.
0
 
LVL 2

Assisted Solution

by:toymachiner62
toymachiner62 earned 200 total points
Comment Utility
There might be a better fix than this but since the background color of lime won't be visible unless you have some padding on the divCell, you can just eliminate "background-color:lime;" and add "padding:1px;" to the divRow.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now