Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Background color not being displayed in a floated div (IE7 Only)
Old 07-24-2008, 05:36 PM Background color not being displayed in a floated div (IE7 Only)
Average Talker

Posts: 15
Name: John Holmes
Trades: 0
Here's another strange IE7 bug I hope somebody can help me with. It started when the rounded corners on a floated div would not display. I've now worked it down to this small test page with colors instead images:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Test</title>
    <style type="text/css">
        .top, .bottom { 
            background-color: blue;
            height: 10px;
        }
        .inside {
            background-color: green;
            text-align: center;
            height: 20px;
        }
        .outside {
            padding: 6px;
            background-color: red;
            float: right;
        }
    </style>

</head>

<body>

    <div class="outside"><div class="top"></div><div class="inside">Test</div><div class="bottom"></div></div>

</body>
</html>
You'll notice that the top and bottom divs are not displaying the blue background color that they should. However, if you remove the float tag from the outside class, you'll see the blue background. Does anybody have any idea how to fix this?

Thanks!
__________________
MyDropSpot (mydropspot.com) Creator/Owner/Administrator
FiZiX is offline
Reply With Quote
View Public Profile Visit FiZiX's homepage!
 
 
Register now for full access!
Old 07-24-2008, 09:36 PM Re: Background color not being displayed in a floated div (IE7 Only)
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I think it's because the top and bottom divs have no width. They want to inherit the width from the outside div, but that also hasn't been defined. When you take the float away the width of the outside div defaults to the width of the body and all the internal divs inherit as well.

If you give the top and bottom divs a width or instead add a width to the outside div you'll see the blue background.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-25-2008, 09:46 AM Re: Background color not being displayed in a floated div (IE7 Only)
Average Talker

Posts: 15
Name: John Holmes
Trades: 0
Thanks, that was it! You are a scholar and a gentlemen.
__________________
MyDropSpot (mydropspot.com) Creator/Owner/Administrator
FiZiX is offline
Reply With Quote
View Public Profile Visit FiZiX's homepage!
 
Old 07-25-2008, 07:49 PM Re: Background color not being displayed in a floated div (IE7 Only)
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Glad to help
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Background color not being displayed in a floated div (IE7 Only)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.16509 seconds with 12 queries