Solved

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

Posted on 2009-07-10
2
407 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
ID: 24825834
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
ID: 24825854
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

932 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

21 Experts available now in Live!

Get 1:1 Help Now