Click to See Complete Forum and Search --> : CSS Layout Help -- Make the gaps stop!


cdxrevvved
12-13-2002, 07:48 PM
CSS Layout Help -- Make the gaps stop!

Ok. Here is the url for the page :

PAGE LINK (http://cdxrevvved.mine.nu/web/ecommerce/testlayout2/test2.htm)

Now, I cant preview in any browsers right now (work) except netscape 4.7 and IE 5.5 ... But when previewing in IE, I get these gaps in between my columns! They should line up properly with them totaling 100% width..

If you want the rest, just view the source on the page..

WHY are these gaps there and HOW do I make them go away? I'd hate to start using tables again... {grin}

The code is below...


CDXRevVveD




<style type="text/css">
body {
background-color: silver
}

#positioned-element
{
background-color: red;
height: 115 px;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
z-index: 1
}

#positioned-element1
{
background-color: pink;
height: 20 px;
left: 0px;
position: absolute;
top: 115px;
width: 100%;
z-index: 2
}

#positioned-element2
{
background-color: blue;
height: 400 px;
left: 0 px;
position: absolute;
top: 135px;
width: 20%;
z-index: 3
}

#positioned-element3
{
background-color: white;
height: 400 px;
left: 20%;
position: absolute;
top: 135px;
width: 50%;
z-index: 4
}

#positioned-element4
{
background-color: gray;
height: 400 px;
left: 70%;
position: absolute;
top: 135px;
width: 30%;
z-index: 5
}

</style>

Zach Elfers
12-13-2002, 08:47 PM
In the <body> tag put <body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">. That will fix your problem.

cdxrevvved
12-13-2002, 09:00 PM
Please, cover your ears, with such a simple solution, I am now going to scream at the top of my lungs... :)

Thanx for the help...

Also, how do i put a footer on my page using css? Ive seen it, but Im still way too new...

Zach Elfers
12-13-2002, 09:06 PM
What kind of footer? Please give some details.

cdxrevvved
12-13-2002, 09:18 PM
basically a bar, 100% width, about 30 pixels tall, at the bottom of the page.. (after the 3 columns on the test page).. so far the only way I know to do it would limit the height of my 3 columns..

I just want a footer at the end of the 3 columns, going all the way across, bout 30 pixls tall or so...

I wouldnt think it would be so difficult.. at least with tables it wasnt.. :)

Zach Elfers
12-13-2002, 09:22 PM
<div style="width:100%;height:30px;position:relative;top:0px;left:0px;">Contents</div>

That would do it.

Don't worry about setting a height and width to divs. They will expand to fit the contents, unless you specify for them not to.

cdxrevvved
12-13-2002, 09:29 PM
my only prob is its at the top of the page.... how do i make it the last element on the page.. I know the three columns in the middle with ALWAYS be of varying height, so I cant just say put the footer 30 pixels from the bottom, or can i?

CLICK FOR EXAMPLE (http://cdxrevvved.mine.nu/web/ecommerce/testlayout2/test2.htm)

Zach Elfers
12-13-2002, 09:34 PM
Use position:absolute;top:1000000000000000000000000000000000000000000000000000000000000000px;left:0px;




NOTE: Do not really put all those zeros.

Stefan
12-13-2002, 09:37 PM
Originally posted by cdxrevvved

If you want the rest, just view the source on the page..


Ok did that and the first line caught my eye to begin with
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

Where did you find that code?
It should be
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
or preferably
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

After that you should also add a charencoding to your page and default script and style language, leaving us with something like
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">

Now we can rip out that proprietary crapcode you just added (marginheight="0" marginwidth="0" leftmargin="0" topmargin="0") as well as the 3 bogus meta declarations you use now.

Once you completed these steps you will have a valid base to stand on to which you can add your CSS to.

Stefan
12-13-2002, 09:42 PM
Originally posted by cdxrevvved
my only prob is its at the top of the page.... how do i make it the last element on the page.. I know the three columns in the middle with ALWAYS be of varying height, so I cant just say put the footer 30 pixels from the bottom, or can i?

CLICK FOR EXAMPLE (http://cdxrevvved.mine.nu/web/ecommerce/testlayout2/test2.htm)

Yes, you can put them at the end, but you need to remake the entire CSS layout to not rely on positioned elements for it's main content.
I'll help you with that if you like when after you fix the other problems.

cdxrevvved
12-13-2002, 09:50 PM
The doctype came from using a wysiwyg css editor, layoutmaster or something.. its a companion prog to stylemaster.. just downloaded that last nite to try it out

cdxrevvved
12-13-2002, 09:55 PM
Ok.. so i changed the doctype , dropped the body margin, etc, now everything has the gaps again.... so how would I do it?

Stefan
12-13-2002, 10:00 PM
Originally posted by cdxrevvved
Ok.. so i changed the doctype , dropped the body margin, etc, now everything has the gaps again.... so how would I do it?

body {margin:0;}

cdxrevvved
12-13-2002, 10:14 PM
Ok... now i see... Im doing my best to stay away from tables...

But now, how would I go about doing the footer, its still at the wrong end of the screen.. :)

BTW, thanx for putting up with me.... We are all newbies at soemthing...

Zach Elfers
12-13-2002, 10:17 PM
Cut and Paste your footer to the bottom of the HTML coding. Right now it is the topmost element. This won't completely fix your problem though.

Stefan
12-13-2002, 10:21 PM
Originally posted by cdxrevvved
But now, how would I go about doing the footer, its still at the wrong end of the screen.. :)


Try something like this :)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Test Layout</title>
<style type="text/css" title="Default" media="screen">

body {background:white; margin:0; padding:0;}

#topbar {background:red; height:115px;}
#menu {background:#FFC0CB;}
#left {float:left; width:20%; background:blue; }
#right {float:right; width:30%; background:gray;}
#footer {background:yellow; clear:both;}

</style>
</head>
<body>

<div id="topbar">TOP BAR</div>

<div id="menu">menu bar</div>
<div id="left">left colum</div>
<div id="right">right column</div>

main content

<div id="footer">your footer</div>

</body>
</html>

Depending on exactly how you want the page to behave there are some variations on this theme you could use. But I would really need to see some real content on your page or a description of how it to be able to recomend something specific.

cdxrevvved
12-13-2002, 11:23 PM
actually, it is the last bit of html, right before the </body> tag

cdxrevvved
12-13-2002, 11:27 PM
actually, that worked awesome.. thanx to the both of ya..

just one more question.. what does the clear:both mean?

Stefan
12-13-2002, 11:45 PM
Originally posted by cdxrevvved
just one more question.. what does the clear:both mean?

It ensures the left and right column doesn't overlap the footer in case they are longer then the main content.

Also, I'm almost sure this is not the Ultimate&trade; solution for you, but toy with it and complain about things that don't work as you would like it to and I'll show how to make it behave exactly as you like.

cdxrevvved
12-14-2002, 04:21 PM
Ok.. been playing around.. and this is the "BASIC" layout.. got a lot more to do such as removing the tables from the left and right columns {grin}...

But thats the idea..

Test Layout 4 (http://cdxrevvved.mine.nu/web/ecommerce/testlayout2/test4.php)

I think I'm well on my way tho.. Ignore the look / layout of the left and right columns content, those were copied and pasted from another test layout originally thrown together in 10 mins with tables...

If ya have any ideas / suggestions, please feel free to hollar at me.. :)

Stefan
12-14-2002, 05:19 PM
Originally posted by cdxrevvved

I think I'm well on my way tho.. Ignore the look / layout of the left and right columns content, those were copied and pasted from another test layout originally thrown together in 10 mins with tables...

If ya have any ideas / suggestions, please feel free to hollar at me.. :)

Yepp, does seem like you are well into getting aquanted with CSS :)

A suggestion on the way from me would be that you make also a page with long center content and see what "happens". If you don't like how things behave it's better to decide on a layout that works more like you wold want it as soon as possible in the proces (since it cuts down on the extra work converting from one to the other).

And BTW, don't use stuff like
<center>
Use CSS instead :)

A few other tips
{background:white; background-image:url("../images/oldpaper.jpg");
can be written shorter as
{background:white url("../images/oldpaper.jpg");

Also you accidentally placed a - instead of : in
background-transparent;}

cdxrevvved
12-14-2002, 07:06 PM
the <center> 's are there temporarily. Eventually all of that will be removed.. My goal is to do the site entirely with php and css combined, skipping out on as much html as possible.

Thx for pointing out the little helpers like the backgroudn transparent, etc.

And yeah, I'm going to go add some more center content here in just a little bit, so we will see if it still works... :)

King Pellinore
12-14-2002, 07:56 PM
Try this, it is a bit longer, but now you get your columns go the whole way (If you want background for them), independent of the content (the content will stay in the middle column):


Leave the top bar and the menu as they are
Leave the footer as it is
Insert a DIV, called say "trunk" between the menu and the footer. Style it- background: blue; (Still using the first layout colours here for clarity)
Insert DIV and call it like "gray_trunk" inside the "trunk". Style: margin-left: 20%; backgound: gray;
Insert DIV called "main_content" inside the "gray_trunk". Style: margin-right: 30%; background: white.


This will give you three columns. It will work as long as the content in the middle column is the longest.

But how do you insert content in the columns?
Here:

You need to put the left column inside the "trunk". To do this, change the style of the trunk: position: relative; width: 100%.
Notes: "relative" is the same as "static", except that it creates a new reference system inside the object. So, when you absolutely position the "left_column", the position is going to be counted from the top left corner of the "trunk", not the main body. Also: you need to specify a dimension if you want the "relative" bit to work. That's why I used "width: 100%", though it's the default value.
Insert "left_column" inside "trunk". Style: position: absolute; width: 20%; top: 0px;
left: 0px.
Do the same for the second menu. Note: it is to be placed inside the "grey_trunk", so change it's position: to relative as well, etc.

(I saw this technique being used, when they tried to redesign WebRef main page with CSS.)

Here's my code:
_____________________
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Test Layout</title>
<style type="text/css" title="Default" media="screen">

body {
background: white;
margin: 0px;
padding: 0px;}

#topbar {
background: red;
height: 115px;}

#menu {background: #FFC0CB;}

#trunk {
position: relative;
width: 100%;
background: blue;}

#gray_trunk {
position: relative;
width: 100%;
margin-left: 20%;
background: gray;}

#main_content {
margin-right: 30%;
background: white;}

#left_column {
width: 20%;
position: absolute;
top: 0px;
left: 0px;}

#right_column {
width: 30%;
position: absolute;
top: 0px;
right: 0px;}

#footer {background: yellow;}

</style>
</head>
<body>

<div id="topbar">TOP BAR</div>
<div id="menu">menu bar</div>

<div id="trunk">
<div id="left_column">left column</div>
<div id="gray_trunk">
<div id="main_content">
main content<BR>more<BR>more<BR>more<BR>more<BR>more<BR>more<BR>more
</div>
<div id="right_column">right column</div>
</div>
</div>
<div id="footer">your footer</div>

</body>
</html>

____________
damn, all the indentation's gone

cdxrevvved
12-14-2002, 08:33 PM
Interesting approach, and this may work, so long as I follow your advice and keep the center column the longest.. I'll start formatting and exerimenting here in a bit.. thx!

cdxrevvved
12-14-2002, 09:06 PM
Using the approach above, with the trunk script (which I will cal it from now on), here it is for anyone interested...

Angels Things Test Layout (http://cdxrevvved.mine.nu/web/ecommerce/testlayout2/test5.php)

THe code has a TON of cleanup to be done, mostly in the PHP sections which are combined with regular html tables to parse the database, to pull the information.. Thats the biggest thing, is everything on the right is dynamically pulled and arranged into neat columns, which I now need to do somehow in css.. As i said, I dont want any tables in my code anymore..

And just a furthur note, thanks for all the help you guys. Half the other boards I would post on, they would tell me to go rtfm... :)

Stefan
12-14-2002, 09:59 PM
Originally posted by King Pellinore
#gray_trunk {
position: relative;
width: 100%;
margin-left: 20%;
background: gray;}


This will force a horizontal scrollbar in all nonbuggy browsers AT ALL RESOLUTIONS since you are making the page 120% = 1.2x the width of the screen.

I'd recomend you to upgrade that old buggy IE 5.x to IE 6 as well as download Opera 7b and eg Mozilla 1.2.1..
That way you would notice such logical errors in your code :)

cdxrevvved
12-14-2002, 10:15 PM
well, to make it worse, here at work, with ie 5.5, it looks awesome.. but i dont have any other browsers to test it on.. and cant download anything.. so, i'll look at it when I get home and go from there...

King Pellinore
12-14-2002, 10:17 PM
Originally posted by Stefan
This will force a horizontal scrollbar in all nonbuggy browsers...

What's a nonbuggy browser?
(Amaya maybe)

Yeah, I know, my IE5.5 treats the percentages differently. But this is a fixable flaw.

Stefan
12-14-2002, 10:42 PM
Originally posted by King Pellinore
[B]What's a nonbuggy browser?


In regard to getting margins correctly?
ALL browsers except IE/Win 5.x (even IE 6 and IE/Mac 5.x do as they are suposed to).

That is 60% of the browsers in use and a number that is also steadly increasing as more and more people upgrade their old crappy IE browser.