Forum Moderators: not2easy

Message Too Old, No Replies

positioning problems

         

viirin

4:53 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



Hey guys,

I was reading through the forums a bit looking for a solution, and while I wasn't able to find something that helped me figure out my problem, it seems like there are some knowledgable people here who might be able to help me.

That said, I am having 2 basic problems.

Firstly, When my content exceeds view of of the screen, and one scrolls down to view it, there is whitespace. The text from the "main" div is visible, but the whole design of the page is screwed up. I cannot figure out how to fix this, as if I do not define a height for those divs then they disappear.

Secondly, I am attempting to add a footer to the page, which will be at the bottom of the page if there is not enough content, but will push down as the content pushes it down. I have seen a few solutions for this here, but I thus far haven't been able to apply them to my page.

The site I am designing is for a friend's business, it can be viewed here: <snip>

Here is the CSS:


html, body {
min-height: 100%;
width: 100%;
}
#outer {
position: relative;
width: 100%;
min-height: 100%;
background: #b39900 repeat-y;
}
#inner {
position: relative;
left: 150px;
width: 724px;
min-height: 100%;
background: black repeat-y;
}
#top {
position: relative;
top: 0px;
left: 0px;
text-align: center;
background-color: blue;
}
#topleft {
position: absolute;
left: 0px;
top: 0px;
background-color: white;
min-height: 80px;
}
#head {
position: absolute;
top: 80px;
left: 0px;
background-color: red;
width: 724px;
height: 20px;
}
#left {
position: absolute;
left: 0px;
top: 80px;
background-color: yellow;
color: white;
}
#main {
position: relative;
left: 10px;
top: 100px;
background-color: green;
}
#right {
position: absolute;
top: 0;
left: 724px;
width: 150px;
height: 100%;
background-color: orange;
}
#bottom {
position: absolute;
bottom: 0px;
left: 0px;
background-color: purple;
}
#footer {
position: relative;
bottom: 0px;
background-color: pink;
}

And here is some stripped down html:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Testing Ground</title>
<meta name="generator" content="Amaya, see http://www.w3.org/Amaya/" />
<link href="testingground.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="outer">

<div id="topleft">
<p>testtesttest</p>
</div>

<div id="left" style="z-index: 2"><div id="menu">
</div>
</div>
<div id="inner" style="z-index: 1">
<div id="top">
<p>testtesttest</p>
<div id="head">
</div>
</div>

<div id="main">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus blandit leo ut erat. Nulla libero felis, condimentum ac, sagittis iaculis, vestibulum id, nibh. Vivamus laoreet risus quis nulla pellentesque varius. Fusce vel risus. Mauris sed mi vel nibh ultrices feugiat. In ac nibh at leo consectetur tincidunt. Vivamus eleifend lobortis quam. Morbi congue, massa nec vestibulum sollicitudin, elit neque fermentum orci, in condimentum erat nisi quis urna. Pellentesque sollicitudin placerat nunc. Aenean hendrerit ultrices dolor.
</p>
</div>
</div>
</div>
</body>
</html>

Note that neither the CSS nor the html properly represent exactly the page I linked to, I posted that link simply to try to illustrate what I am trying to do. If it wasn't for the problems with too much content, it would be exactly what I want.

Thanks in advance for the help guys.

[edited by: swa66 at 6:54 pm (utc) on Mar. 4, 2009]
[edit reason] No personal links please. See ToS [/edit]

CSS_Kidd

6:36 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



Upon looking at the link there are some huge fixes you can do to make this work. First off unless you are planning on adding content to the right side later I would just forget about making that side all together. make the body background that yellow color and and go from there. I am assuming you want the left side to extend with the page content. You can't have the left absolute. it needs to be relative to follow the 100% of the whole body of the page. Take the absolute positioning off of the #left and float it instead. then add a <br style="clear:both;" /> (or a div if you want)before you close the div that wraps those two divs. Then place your footer under that.

I am afraid you might be doing more than you need too.

viirin

7:59 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



You may be right, it is quite possible that I am over-complicating it. What I *WANT* to do is have the left bar with the navigation menu, then, the main content area. Then, on high-resolution screens, rather than having everything stretch out across the whole screen, I want to make the content stop, and then have the same color as the left side continue across to the end of the screen. That was what I was trying to accomplish.

At any rate, I have tried to simplify it (though with what I have done at the moment I lose that right side).

It is still not displaying properly, however.

This is screen of what I get (hopefully this is in accordance with rules, just want to show what problem I am having):

<snip>

Note that I want the white parts to connect, with no gold between. The gold should be only on the side.

Here is the code that gets me there.

CSS:


html, body {
min-height: 100%;
height: 100%;
width: 100%;
background-color: #b39900;
}
#top {
position: relative;
float: right;
top: 0px;
left: 0px;
text-align: center;
background-color: white;
width: 800px;
}
#topleft {
position: absolute;
left: 0px;
top: 0px;
background-color: white;
min-height: 80px;
}
#head {
position: relative;
float: right;
top: 0px;
left: 0px;
background-color: red;
width: 800px;
height: 20px;
}
#left {
position: relative;
float: left;
left: 0px;
top: 80px;
width: 150px;
color: white;
}
#main {
position: relative;
float: right;
left: 0px;
top: 0px;
width: 800px;
background-color: white;
}
#bottom {
position: relative;
float: right;
bottom: 0px;
left: 0px;
background-color: purple;
}
#footer {
position: relative;
bottom: 0px;
background-color: pink;
}

HTML:


<body>
<div id="outer">

<div id="topleft">
<img alt="logo" src="images/logo2A_1-tiny.png" />
</div>

<div id="left" style="z-index: 2"><div id="menu">
<?php

include "menu.php";

?>

</div>
</div>

<div id="inner" style="z-index: 1">

<div id="top">
<img alt="logo" src="images/header.png" width="708" height="75" align="left">

<div id="head">
</div>
</div>

<div id="main">

<p>
<?php

include "index.txt";

?>
</p>
</div>

<div id="right">

</div>
</div>
<div id="spacer">
</div>

<div id="bottom" style="clear: both;">
<div id="footer">

<?php
include "footer.txt";

?>

</div>
</div>

</div>
</body>
</html>

[edited by: swa66 at 9:00 pm (utc) on Mar. 4, 2009]
[edit reason] No personal URLs, see ToS [/edit]

CSS_Kidd

8:43 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



Ok this is what I put together real quick just to start with. I made each div different colors so you can see what you are dealing with. I didn't get the exact 100% height on both to work for all browser yet. I just laid it out for you real quick to give you an idea of the simplicity you can use

<!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>
<style type="text/css">
<!--
* {
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
width: 100%;
}
body {
font: 10px Verdana, Arial, Helvetica, sans-serif;
background: #FFFF99;
}
#mainContent_wrap {
width: 874px;
background: #FFFFFF;
position: relative;
height: 100%;
}
#header {
background: #999999;
height: 80px;
width: 874px;
}
#menu_left {
width: 150px;
border-right: 1px solid #000000;
clear: left;
float: left;
background: #FFCCFF;
height: 100%;
}
#menu_left ul {
border: 1px solid #000000;
list-style: none;
}
#menu_left li {
border: 1px solid #999999;
}
#menu_left li.menu_head {
font-size: 14px;
font-weight: bold;
background: #CCCCCC;
padding: 5px;
text-align: center;
}
#menu_left li.non_link {
font-size: 12px;
font-weight: bold;
padding: 5px;
color: #FFFFFF;
background: #000000;
}
#menu_left li a {
padding: 5px;
display: block;
background: #CCCCCC;
}
#menu_left li a:hover {
background-color:#666666;
}
#page_content {
width: 702px;
float: left;
padding: 10px;
background: #99CCCC;
height: 100%;
}
.clear_float {
font-size: 0px;
line-height: 0px;
clear: both;
height: 0px;
}
-->
</style>
</head>

<body>

<div id="mainContent_wrap">
<div id="header">Header</div>
<div id="menu_left">
<ul>
<li class="menu_head">Menu</li>
<li class="non_link">Main Stuff</li>
<li><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
<li class="non_link">Contact</li>
<li><a href="#">FAQs</a></li>
<li><a href="#">Foo</a></li>
</ul>
</div>
<div id="page_content">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis ligula lorem, consequat eget, tristique nec, auctor quis, purus. Vivamus ut sem. Fusce aliquam nunc vitae purus. Aenean viverra malesuada libero. Fusce ac quam. Donec neque. Nunc venenatis enim nec quam. Cras faucibus, justo vel accumsan aliquam, tellus dui fringilla quam, in condimentum augue lorem non tellus. Pellentesque id arcu non sem placerat iaculis. Curabitur posuere, pede vitae lacinia accumsan, enim nibh elementum orci, ut volutpat eros sapien nec sapien. Suspendisse neque arcu, ultrices commodo, pellentesque sit amet, ultricies ut, ipsum. Mauris et eros eget erat dapibus mollis. Mauris laoreet posuere odio. Nam ipsum ligula, ullamcorper eu, fringilla at, lacinia ut, augue. Nullam nunc.</p>
<p>&nbsp;</p>
<p>Sed et lectus in massa imperdiet tincidunt. Praesent neque tortor, sollicitudin non, euismod a, adipiscing a, est. Mauris diam metus, varius nec, faucibus at, faucibus sollicitudin, lectus. Nam posuere felis ac urna. Vestibulum tempor vestibulum urna. Nullam metus. Vivamus ac purus. Nullam interdum ullamcorper libero. Morbi vehicula imperdiet justo. Etiam mollis fringilla ante. Donec et dui. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Etiam mi libero, luctus nec, blandit ac, rutrum ac, lectus.</p>
<p>&nbsp;</p>
<p>Morbi consequat felis vitae enim. Nunc nec lacus. Vestibulum odio. Morbi egestas, urna et mollis bibendum, enim tellus posuere justo, eget elementum purus urna nec lacus. Nullam in nulla. Praesent ac lorem. Donec metus risus, accumsan ut, mollis non, porttitor eget, mi. Aliquam aliquet, tortor a elementum aliquam, erat odio sodales eros, suscipit blandit lectus dolor sit amet elit. In eros wisi, mollis vitae, tincidunt in, suscipit id, nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Phasellus ornare. Suspendisse potenti. Mauris convallis. Vestibulum nec mauris in augue porta mollis. Proin ut nunc. Mauris aliquam dui eget purus.</p>
<p>&nbsp;</p>
<p>Sed ut metus sed wisi commodo viverra. Suspendisse dignissim elit ac leo. Fusce magna augue, accumsan eu, sollicitudin ut, ultricies eu, elit. Vestibulum faucibus turpis at lacus. Nulla pede nibh, congue ac, luctus at, pharetra ut, nulla. Nulla in ipsum eget tortor lobortis laoreet. Morbi molestie nibh dapibus justo. Nulla sapien lorem, tincidunt sit amet, lobortis laoreet, feugiat a, leo. Etiam id mauris in libero molestie dictum. Cras nisl diam, dapibus ut, sollicitudin sed, auctor nec, orci. Nam eleifend, dui in dapibus congue, mi diam luctus velit, eu imperdiet pede elit nec lorem. Proin laoreet, eros a dictum faucibus, nunc wisi rhoncus nunc, at rhoncus lectus tellus vitae urna. Curabitur a turpis at ligula lobortis cursus.</p>
<p>&nbsp;</p>
</div>

<br class="clear_float" />
</div>
</body>
</html>

viirin

9:08 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



Thanks.

I am going to go through that and see if I can't figure out how to apply it.

I appreciate the help. I probably won't get a chance to work on it anymore until tonight, but what you've given me here should get me going in the right direction I think.

CSS_Kidd

9:56 pm on Mar 4, 2009 (gmt 0)

10+ Year Member



After you get it laid out then it's time to work on the 100% height which is the hard part and there are various ways to attempt. But lets start with what you have and re-post a screen shoot or link of the page when you done with the above, then we can move on.

viirin

3:26 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



Ok, so I didn't have time to get to it last night and am working with it now. I think with the exception of the footer, this will get me to where I want the site to be (I pretty much have it there now). I am looking at the CSS though and not understanding how the floats are working... apparently the way I understand floats in my head is not correct. Do you know of a good float tutorial I might be able to go through that will explain it to me? If not, I will attempt to find one on my own.

[edited by: tedster at 9:09 am (utc) on Mar. 7, 2009]

CSS_Kidd

3:52 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



Floats are tricky and every body has a way of handling them. There are many tutorials out there to explain the basics of dos and don'ts with floats. Here is a basic one that not only explains but gives some good examples [brunildo.org ]. just click the float link there.

viirin

7:12 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



Ok, I have finished the modifications... So now the problem is once again that the design breaks down once the content extends past the viewable area of the screen.

I'll start trying to figure it out on my own, but whatever help you can give would be most appreciated. <snip>

[edited by: swa66 at 1:12 am (utc) on Mar. 6, 2009]
[edit reason] keep the discussion in the forum please [/edit]

viirin

3:27 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



I am still having the same problem with the container not extending with the content.

Here is our current 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>
<style type="text/css">
<!--
* {
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
}
body {
font: 10px Verdana, Arial, Helvetica, sans-serif;
background: #B39900;
}
#header {
height:80px;
width:874px;
position:absolute;
top:0px;
left:0px;
z-index:1;
background:#FFFFFF;
}
#menu_leftSide {
background: #B39900;
width: 150px;
border-right: 1px solid #000000;
min-height:100%;
max-height:100%;
left: 0px;
top: 0px;
position: relative;
clear: left;
float: left;

}
#menu_left {
padding-top:80px;
}
#menu_left ul {
border:1px solid #000000;
list-style-image:none;
list-style-position:outside;
list-style-type:none;
}
#menu_left li {
border:1px solid #999999;
}
#menu_left li.menu_head {
background:#CCCCCC;
color:#FFFFFF;
font-size:12px;
font-weight:bold;
padding:0;
text-align:center;
text-decoration:none;
}
#menu_left li.non_link {
background:#000000;
color:#FFFFFF;
font-size:12px;
font-weight:bold;
padding:5px;
}
#menu_left li a {
background:#CCCCCC;
color:#000000;
display:block;
padding:5px;
text-decoration:none;
}
#menu_left li a:hover {
background-color:#666666;
}
#content_rightSide {
background:#CCCCCC;
width:723px;
min-height:100%;
max-height:100%;
position: relative;
top: 0px;
margin-left: 151px;

}
#divider {
background:#B39900 url(images/bar2.png) repeat-x bottom;
height:20px;
padding-top: 80px;
}
#footer {
background:#000000;
width:713px;
position:absolute;
bottom:0px;
color: #FFFFFF;
padding: 5px;
}
.content_text {
text-align: justify;
padding: 10px;
}
-->
</style>
</head>

<body>
<div id="header">
<img src="images/logo.png" alt="Logo" height="80" width="150" />
<img src="images/header.png" alt="Title" height="75" width="708" />
</div>
<div id="menu_leftSide">
<div id="menu_left">
</div>
</div>
<div id="content_rightSide">
<div id="divider"></div>
<div class="content_text">
</div>

<div id="footer">Content for id "footer" Goes Here</div>
</div>
</body>
</html>

So what we still need to figure out is:

1.) Extending the containers with the content.
2.) IE6 specific fixes.

Anyone else have any input?

[edited by: tedster at 9:10 am (utc) on Mar. 7, 2009]

[edited by: swa66 at 9:58 pm (utc) on Mar. 7, 2009]
[edit reason] disable graphic smile faces [/edit]

CSS_Kidd

3:36 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



It worked for me in Firefox, Safari and Opera. Just tested it again. What browser are you using to look at it.. If it's another IE (7 or beta 8) maybe need to look for fixes for that as well.

Also the max-height may not be needed.

CSS_Kidd

3:43 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



Yes take out the max-height (not needed for this particular layout)

viirin

3:58 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



I'm using firefox. You're sure that's the same code you pmed me? When I add content to extend the container, the text still overflows from it and the design breaks down.

CSS_Kidd

4:12 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



Yep Same code. I just added a whole bunch of content so I would get a scroll. No break downs, no overflows anything. Works great in Firefox. What kind of content did you add? any floats that have absolute positions? did you add it into the .content_text div? That's where all page content should go, and not directly in the #content_rightSide div. Especially if they are positioned absolute.

viirin

4:41 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



I will test again and make sure it's in that div. I may not have been paying close enough attention and put it in the other div.

viirin

2:41 pm on Mar 7, 2009 (gmt 0)

10+ Year Member



Ok, that situation was resolved. All that remains is IE fixes. Can anyone help with this?

swa66

11:11 pm on Mar 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest you add conditional comments [webmasterworld.com] that target just one version of IE and slowly build up workarounds for the IE bugs/features in it.

If (or when) you run into a roadblock, try making a new post about that problem, by carefully reading the how to post code guidelines [webmasterworld.com] and the CSS troubleshooter guide [webmasterworld.com] pinned at the top of this forum. Remember the more work you do on minimizing the code needed to reproduce the problem, the more likely you are to find an answer from people out here (or find it for yourself).

Also remember we're not here to do your homework, we're in it to learn (or teach). So consider us not people who're not so likely to give you a fish, but who'd rather try to show you how to catch fish yourself.