Reply
What's wrong with my div layout?
Old 11-20-2008, 10:10 PM What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
I am new to divs, so any suggestions on how to do certain stuff would be very helpful





That's basically what I'm looking for. Here's my code.

Code:
/*******************LAYOUT*******************/
/*********CONTAINER*********/

#container
{
width: 800px;
margin: 50px 0px auto;
background-color: #feffe9;
}

/*********LINKS*********/
#links
{
position: absolute;
top: 0px;
left: 0px;
width: 800px;
background-color: #FF0000;
}

/*********HEADER*********/
#header
{
position: absolute;
top: 84px;
left: 0px;
width: 800px;
background-color: #CC9900;
}

/*********CONTENT*********/
#content
{
position: absolute;
top: 260px;
left: 0px;
width: 550px;
background-color: #FFFF00;
clear: both;
}

/*********LINKS-RIGHT*********/
#linksright
{
position: absolute;
left: 550px;
width: 250px;
background-color: #00FF00;
clear: none;
}

/*********ADVERTISERS*********/
#advertise
{
position: absolute;
left: 550px;
width: 250px;
background-color: #0000FF;
clear: none;
}

/*********CONTAINER*********/
#copyright
{
position: absolute;
top: 750px;
left: 0px;
width: 800px;
background-color: #993399;
}
/*******************END LAYOUT*******************/
And the HTML:

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<link href="home.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="container">
<div id="links">&nbsp;</div>
<div id="header">&nbsp;</div>
<div id="content">&nbsp;</div>
<div id="linksright">&nbsp;</div>
<div id="advertise">&nbsp;</div>
<div id="copyright">&nbsp;</div>
</div>
</body>
</html>
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-20-2008, 10:18 PM Re: What's wrong with my div layout?
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
The first thing you should do, as I'm sure many other people here will suggest, is stop positioning everything absolutely. You don't need positioning at all to do what you describe, and in fact it is a hindrance, not a help. Learn the process of floating and clearing <div>s that have a set width, so that the data naturally flows inside of containers, instead of being "nailed down" all over the place.

Floating and Clearing.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-20-2008, 10:47 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
The first thing you should do, as I'm sure many other people here will suggest, is stop positioning everything absolutely. You don't need positioning at all to do what you describe, and in fact it is a hindrance, not a help. Learn the process of floating and clearing <div>s that have a set width, so that the data naturally flows inside of containers, instead of being "nailed down" all over the place.

Floating and Clearing.
Code:
/*******************LAYOUT*******************/
/*********CONTAINER*********/

#container
{
width: 800px;
margin: 50px 0px auto;
background-color: #feffe9;
overflow: auto;
}

/*********LINKS*********/
#links
{
width: 100%;
background-color: #FF0000;
}

/*********HEADER*********/
#header
{
width: 100%;
background-color: #CC9900;
}

/*********CONTENT*********/
#content
{
width: 69%;
background-color: #FFFF00;
clear: left;
}

/*********LINKS-RIGHT*********/
#linksright
{
width: 31%;
background-color: #00FF00;
clear: right;
}

/*********ADVERTISERS*********/
#advertise
{
width: 31%;
background-color: #0000FF;
clear: right;
}

/*********CONTAINER*********/
#copyright
{
width: 100%;
background-color: #993399;
}
/*******************END LAYOUT*******************/
I still have that stupid thing happening where it shows each div on line after line. I want the #content to go left of the links and advertisements. The height of #content should = links+advertisements.
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 05:56 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
This is strange, the linksright and advertising (the one underneath the linksright) are right and underneath the content. I want the linksright and ads to go right of the content but I want the ads to stretch down as far as the content goes, so there is no blank space underneath it. How can I do that?

Code:
body
{
background-color: #feffe9;
}

/*******************LAYOUT*******************/
/*********CONTAINER*********/

#container
{
width: 1000px;
margin: 0px auto;
background-color: #feffe9;
overflow: auto;
}

/*********LINKS*********/
#links
{
width: 1000px;
clear: both;
background-color: #FF0000;
}

/*********HEADER*********/
#header
{
width: 1000px;
clear: both;
background-color: #CC9900;
}

/*********CONTENT*********/
#content
{
float: left;
width: 700px;
background-color: #FFFF00;
padding: 2px 5px;
}

/*********LINKS-RIGHT*********/
#linksright
{
float: right;
width: 300px;
background-color: #00FF00;
}

/*********ADVERTISERS*********/
#advertise
{
float: right;
width: 300px;
background-color: #0000FF;
}

/*********CONTAINER*********/
#copyright
{
width: 1000px;
background-color: #993399;
clear: both;
}
/*******************END LAYOUT*******************/

Last edited by HWolfpack6; 11-21-2008 at 05:59 PM..
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 06:47 PM Re: What's wrong with my div layout?
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
The most basic way to do this is with an illusion: Faux Columns.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-21-2008, 07:09 PM Re: What's wrong with my div layout?
Mark Henderson's Avatar
Extreme Talker

Posts: 207
Name: Mark Henderson
Location: Yorkshire
Trades: 0
give me 30 minutes, im going to code this for you, XHTML + CSS. Just because i am nice

I would usually charge about $50 for this, so yeah, im nice.

Is that image above the exact specs you want?
__________________
vLusion - Simple Internet Solutions | Shared / Reseller / Managed Web Hosting
Mark Henderson - Affordable Web/Graphics Design - FREE IMAGE HOSTING
WHOISify - WHOIS Lookup, reverse IP, traceroute and more!
Mark Henderson is offline
Reply With Quote
View Public Profile Visit Mark Henderson's homepage!
 
Old 11-21-2008, 07:09 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
D*mnit...it didn't work. I have the two colors there, but it leaves the space underneath it white still and just puts the yellow/blue in above and beneath the container.
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 07:11 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Quote:
Originally Posted by Mark Henderson View Post
give me 30 minutes, im going to code this for you, XHTML + CSS. Just because i am nice

I would usually charge about $50 for this, so yeah, im nice.

Is that image above the exact specs you want?
Container should be 1000px.
Links should be 1000px.
Header should be 1000px.
Content should be 700px.
Linksright should be 300px.
Ads (which goes right underneath the linksright) should be 300px.
Copyright should be 1000px.

I'd like the ads to stretch it's background color to fit the same length as the content. THANKS A LOT!

EDIT: No, actually, please don't do this. I am going to change the colors of the site, the one above isn't anything what I want it to look like in the end. Plus, the goal of this is to get some experience w/ CSS...so I'd rather do this myself.

Last edited by HWolfpack6; 11-21-2008 at 07:18 PM..
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 07:17 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
OK! Got the layout working great in IE6, it's just Firefox that won't put in the background. It looks like before. Why would this be?
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 07:23 PM Re: What's wrong with my div layout?
Mark Henderson's Avatar
Extreme Talker

Posts: 207
Name: Mark Henderson
Location: Yorkshire
Trades: 0
ok, so you don't need it any more?
__________________
vLusion - Simple Internet Solutions | Shared / Reseller / Managed Web Hosting
Mark Henderson - Affordable Web/Graphics Design - FREE IMAGE HOSTING
WHOISify - WHOIS Lookup, reverse IP, traceroute and more!
Mark Henderson is offline
Reply With Quote
View Public Profile Visit Mark Henderson's homepage!
 
Old 11-21-2008, 07:24 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Quote:
Originally Posted by Mark Henderson View Post
ok, so you don't need it any more?
No, but thank you for your generosity.
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 07:27 PM Re: What's wrong with my div layout?
Mark Henderson's Avatar
Extreme Talker

Posts: 207
Name: Mark Henderson
Location: Yorkshire
Trades: 0
Haha, ok, no problem.
__________________
vLusion - Simple Internet Solutions | Shared / Reseller / Managed Web Hosting
Mark Henderson - Affordable Web/Graphics Design - FREE IMAGE HOSTING
WHOISify - WHOIS Lookup, reverse IP, traceroute and more!
Mark Henderson is offline
Reply With Quote
View Public Profile Visit Mark Henderson's homepage!
 
Old 11-21-2008, 08:43 PM Re: What's wrong with my div layout?
Brian07002's Avatar
Defies a Status

Posts: 1,598
Name: ...
Location: ...
Trades: 0
When using absolute positioning ( DON'T USE IT ) YET first put your structure together, think like this: TOP (Header), BOTTOM (Footer), LEFT (Navigation), RIGHT (AD SPACE / Miscellaneous) CENTER (YOUR WEBSITES MAIN CONTENT)

ONCE YOU GET THAT FAR, THEN YOU CAN USE ABS POSITIONING ALL YOU WANT. You can put image anywhere with abs positioning as well as text, flash banners, videos etc..etc..
__________________
Sig Less - Have some site you want me to put here? Will put here for a couple of paypal bucks.

Last edited by Brian07002; 11-21-2008 at 08:45 PM..
Brian07002 is online now
Reply With Quote
View Public Profile
 
Old 11-21-2008, 09:33 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Quote:
Originally Posted by Brian07002 View Post
When using absolute positioning ( DON'T USE IT ) YET first put your structure together, think like this: TOP (Header), BOTTOM (Footer), LEFT (Navigation), RIGHT (AD SPACE / Miscellaneous) CENTER (YOUR WEBSITES MAIN CONTENT)

ONCE YOU GET THAT FAR, THEN YOU CAN USE ABS POSITIONING ALL YOU WANT. You can put image anywhere with abs positioning as well as text, flash banners, videos etc..etc..
I was told not to use absolute positioning though. Should I redesign the site and use it?
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-22-2008, 11:00 AM Re: What's wrong with my div layout?
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
In my opinion, absolute positioning should be minimal. Before you ever touch it, you need to completely understand the difference and relationship between absolute and relative positioning. Do you?

You shouldn't do any part of the main structure of your site with absolute positioning, unless you're doing something more advanced, and really know what you're doing.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-22-2008, 01:39 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
In my opinion, absolute positioning should be minimal. Before you ever touch it, you need to completely understand the difference and relationship between absolute and relative positioning. Do you?
N-O.

So how would I get this thing working in Firefox?
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-22-2008, 07:28 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
OK, I've got the entire layout working and all, but I try to add padding to the left and right side of the content, and it pushes the links on the right and ads to underneath it. How can I compensate to get the padding of the paragraph but keep the layout in order?
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Old 11-22-2008, 07:45 PM Re: What's wrong with my div layout?
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Padding adds to the width of anything that has width set on it, so you either need to calculate when adding it, or else add the padding to inner elements.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-23-2008, 01:49 PM Re: What's wrong with my div layout?
LadynRed's Avatar
Super Moderator

Posts: 8,823
Location: Tennessee
Trades: 0
Put the padding on the paragraphs INSIDE the div, not on the containing div, that won't break your layout.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 11-23-2008, 05:12 PM Re: What's wrong with my div layout?
Skilled Talker

Posts: 55
Name: Mike
Trades: 0
I tried that, doesn't work though.

p#content
{
line-height: 25px;
padding: 5px;
}

It pushes the padding on the left good, but not the right. The right part goes underneath the ads and linksright div and sends those 2 down underneath the content in IExplorer.

EDIT: Got it, just renamed the paragraph ID's, man, the internet is so quirky.

Last edited by HWolfpack6; 11-23-2008 at 05:17 PM..
HWolfpack6 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to What's wrong with my div 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.20379 seconds with 13 queries