473,385 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CSS positioning problem

4
Hi all,

The height of my page needs to be flexible as the page contains columns with lists which can vary in length. I also have a footer which needs to be stuck to the bottom.

I managed to do all of the above. My problem now is the positioning of the columns. With relative positioning, the columns appear staggered with column2 starting lower than column1.

If I use {float:left}, the two columns stay next to each other which is good but then the footer brings itself up and overlaps with the columns... I don't know if I am clear with my explanation so here is my code. Thanks in advance!


HTML:[html]
<html>
<body>
<div id="container-page">
<div id="container-content">
<div id="container-columns">
<div id="col1">
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
</div>
<div id="col2">
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
</div>
</div >
</div >
<div id="container-foot">footer</div >
</div>
</body>
</html>
[/html]
Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. <!--
  3. #container-page {
  4. left:50%; 
  5. margin-left:-381px; 
  6. width: 762px; 
  7. position: relative; 
  8. top:0px; 
  9. min-height: 100%; 
  10. height: auto; 
  11. height: 100%;
  12. }
  13.  
  14. #container-content {
  15. padding-bottom: 20px;
  16. }
  17.  
  18. #container-foot { 
  19. width: 760px; 
  20. height: 20px; 
  21. position: absolute; 
  22. bottom: 0;
  23. bottom: -1px;
  24. }
  25.  
  26. #container-columns { 
  27. width:760px; 
  28. top: 0px; 
  29. position:relative; 
  30. display:block;
  31. }
  32.  
  33. #col1 { 
  34. position: relative; 
  35. top: 0px; 
  36. left: 1px; 
  37. width: 234px; 
  38. padding-bottom:40px; 
  39. background-color:#cccccc;
  40. }
  41.  
  42. #col2 { 
  43. position: relative; 
  44. top: 0px; 
  45. left: 262px; 
  46. width: 234px; 
  47. padding-bottom:40px; 
  48. background-color:#cc0000; 
  49. }
  50. -->
  51. </style>
Feb 16 '08 #1
6 1496
Hi sooshi,

use float:left and remove the position:absolute style from #container-foot. Kindly, early and often test ur pages through
HTML validator
CSS validator

Good Luck.
Feb 16 '08 #2
drhowarddrfine
7,435 Expert 4TB
And use a proper doctype.
Feb 16 '08 #3
sooshi
4
It works! Thanks guys!
Feb 16 '08 #4
sooshi
4
I have another urgent question concerning the same layout.

(http://cie7273.com/test/test.html)

The column with lists is not correctly aligned horizontally under IE 7. It should be aligned left with the rest of the layout. Instead, it appears a few pixels to the right.

Can anyone tell me what I'm doing wrong?

Thanks in advance
Feb 18 '08 #5
drhowarddrfine
7,435 Expert 4TB
An 'id' is a unique name assigned to only one element on a page. Validate your html for that list of errors, then validate your css for the error there.

If those don't work, add margin:0 and padding:0 to the lists and/or containers.

What's with all the divs around the list?
Feb 18 '08 #6
sooshi
4
Thanks for that. Unfortunately, it doesn't seem to do the trick.
Feb 19 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Tom Szabo | last post by:
Hi, Just wondering if there are any disadvantage in absolute positioning controls on a page? In example instead of putting the text fields into a table to align properly, one would absolute...
9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
4
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
6
by: rajek | last post by:
I posted a similar question yesterday, but didn't get an answer that resolved the issue. (Thanks to those who tried though.) The background: I've read in books and online that if you have one...
9
by: Frances Del Rio | last post by:
I have a pg with lots of divs, one of them is a gray bar about 150px down from the top and 20px from the left... this bar (an image) is 767px wide and 1px high.. however, even though all divs are...
11
by: NS | last post by:
I am relativly new to css positioning and have a question regarding the display of a DHTML pop-up Here is the basic HTML I am using: <html> <head> <script language="JavaScript"> <!--
4
by: TheCeej | last post by:
I'm sorry to post what is ultimately a myspace problem, but I'm sure I'd still be having this problem with any html/css document, so the answer would more than likely be able to help anyone out. I'm...
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
2
by: TheCruelPanda | last post by:
Hey there. My name is Rowan, and it's been three weeks since I last used tables for an HTML design. Okay, I'm rather new to CSS and I have a big positioning problem here. It might not be a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.