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
Problem with CSS Layout
Old 05-21-2005, 07:38 AM Problem with CSS Layout
danburzo's Avatar
Skilled Talker

Posts: 82
Location: Bistrita RO
Trades: 0
I have some nested divs:

Code:
<body>
<div id="page">
   
   <div id="main">
      <div id="content">...</div>
      <div id="right">...</div>
   </div>

</div>
<div id="footer">...</div>
</body>

to which i've applied the styles:


Code:
body {
   text-align: center;
   background: #2E2E2E;
   margin: 0;
   padding: 0;
}

#page {
   width: 750px;
   margin: 0px auto;
   text-align: left;
   background: #FFFFFF;
   }

#main {
   width: 750px;
   background: #FFFFFF;
}

#content {
   width: 510px;
   float: left;
   padding-left: 20px;
   padding-right: 20px;
   padding-top: 20px;
   padding-bottom: 20px;
   background: #FFFFFF;
}

#right {
   width: 159px;
   float: left;
   color: #C03400;
   border-left: 1px dotted #333333;
   padding:20px;
   background: #FFFFFF;
   }

notice that the background color of the page is a dark grey. I want the whole "main" div to have a white background. I've set background:#ffffff, as you see, but it only works in IE.

How can i make it work in Firefox?
danburzo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-21-2005, 09:53 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
background-color is what you need
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2005, 03:41 AM
danburzo's Avatar
Skilled Talker

Posts: 82
Location: Bistrita RO
Trades: 0
Still not working... I mean this isn't the problem, here are some screenshots of what my page looks like in IE and FF:

Firefox:


IE:


I want the page to look somehow like in IE... i mean the whole #main div to have a white background. I think the problem is about the two divs , #content and #right being floats.
danburzo is offline
Reply With Quote
View Public Profile
 
Old 05-22-2005, 04:55 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Your divs aren't nested properly for content and right to affect each other. IE gets it wrong by standards, though it does work as you would expect it to logically and sets child divs without a explicit height to 100% of the parent container though to standards it should be to the contents of the child.

A few small mods gets this

http://www.candsdesign.co.uk/demo/danburzo/

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
   text-align: center;
   background: #2E2E2E;
   margin: 0px;
   padding: 0px;
}

#page {
   width: 750px;
   margin: 0px auto;
   text-align: left;
   background: #FFFFFF;
   }

#main {
   width: 750px;
   background: #FFFFFF;
}

#content {
   float: left;
   padding: 20px 0px 20px 20px;
   background: #FFFFFF;
}

#right {
   width: 159px;
   float: right;
   color: #C03400;
   border-left: 1px dotted #333333;
   padding:0px 20px 20px 20px;
   background: #FFFFFF;
   margin:0px 0px 0px 20px;
   }
#footer {
   position:relative;
   text-align:center;
   clear:both;
   color:#FF0000;
   background-color:#FFFFFF;
}
</style>
</head>

<body>
<div id="page">
   
   <div id="main">
      <div id="content">
Content
	  <div id="right">
Right Side
	  </div> <!-- right -->

      </div> <!-- content -->
   </div> <!-- main -->

<div id="footer">Footer</div>
</div> <!-- page -->

</body>
</html>
Note: if the content in "content" extends below the right side it will wrap around the right side.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 05-22-2005 at 04:58 AM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2005, 04:56 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
hmmmm ....

i remember having problems with exactly that same thing before.

though i remember solving it in a really odd way LOL.

go with chrishirst
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.

Last edited by OmuCuSucu; 05-22-2005 at 05:00 AM..
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 05-22-2005, 06:13 AM
Novice Talker

Posts: 6
Trades: 0
The "content" div is automatically extending to hold it's content. If you set a height value to "content" and "main" of say 100% the background color will extend equally all the way down the page.

In other ways, the background color changes because the "content" div is stopping just below the text.
shaber is offline
Reply With Quote
View Public Profile
 
Old 05-22-2005, 06:55 AM
danburzo's Avatar
Skilled Talker

Posts: 82
Location: Bistrita RO
Trades: 0
Wow, thanks for the replies.

I found another solution: how about clearing the floats:

Code:
<body>
<div id="page">
   
   <div id="main">
      <div id="content">...</div>
      <div id="right">...</div>
      <div style="clear:both">&nbsp</div>
   </div>

</div>
<div id="footer">...</div>
</body>
seems to work as well.
danburzo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with CSS Layout
 

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