Solved

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

Posted on 2009-07-10
2
411 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:
Britt Thompson 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

828 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