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
Nested div loses background and border
Old 08-19-2007, 01:03 AM Nested div loses background and border
Experienced Talker

Posts: 35
Name: Chris
Trades: 0
I'm having trouble with a nested div which is becoming separated from its parent div. The parent div is #page and has a background color and border which I want for the whole page. I'm trying to split the page into two columns using floats. But these become separate from the page div and the background and border end where these divs begin. (I noticed that removing the doctype resulted in the what I was after.)
What am I doing wrong here?

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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Why is this wrong?</title>
<style type="text/css" media="screen">
body{
margin:5px;
background:#333;}
#page{
width:100%;
height:100%;
background:#666;
border:1px solid blue;
}
#leftcol{
width:42%;
float:left;}
#maincol{
width:42%;
float:left;}
p{
color:#fff}
</style>
</head>
<body>
<div id="page">

<div id="head">
<h3>HEAD</h3>
</div><!-- head -->

<div id="leftcol">
<p>Left column</p>
</div><!--leftcol-->

</div> <!--page-->
</body></html>
(...The #head div is fine because it's not being floated, I guess.)
derjavina is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-19-2007, 11:02 AM Re: Nested div loses background and border
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
CLEAR your floats !
http://css-discuss.incutio.com/?page=ClearingSpace

Put a clearing element in after the end of last floated column.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 08-19-2007, 10:05 PM Re: Nested div loses background and border
Experienced Talker

Posts: 35
Name: Chris
Trades: 0
Thankyou!
derjavina is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Nested div loses background and border
 

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 0.20760 seconds with 12 queries