473,395 Members | 1,696 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,395 software developers and data experts.

Making my page 3 column CSS

TheServant
1,168 Expert 1GB
Hey guys,
I am trying to get my page to be 3 columns, with a liquid center one.

The CSS concerned is:
Expand|Select|Wrap|Line Numbers
  1. div.container {
  2.     width: 100%;
  3.     margin: 0 auto;
  4.     border: 0px;
  5. }
  6. div.center_content {
  7.     background-color:#0033FF;
  8.     position: relative;
  9.     left: 200px;
  10.     float: left;
  11. }
  12. div.left_content {
  13.     background-color:#770000;
  14.     width: 200px;
  15.     left: 0;
  16.     position: relative;
  17.     float: left;
  18. }
  19. div.right_content {
  20.     background-color:#7733FF;
  21.     width: 200px;
  22.     right: 0;
  23.     position: relative;
  24.     float: right;
The html:
[HTML]<div class="container">
<div class="left_content">
<p>Left Content</p>
<some code />
</div>
<div class="center_content">
<p>Center Content</p>
<some code />
</div>
<div class="right_content">
<p>Right Content</p>
<some code />
</div>
</div>[/HTML]

Basically I want the middle column to fill all the space between the left and right (fixed-width) columns, but I can't seem to get the CSS right for center_content.
Mar 12 '08 #1
7 1413
harshmaul
490 Expert 256MB
Your always going to get this problem unless you use fixed sizes for everything.

Either use pixels as the measure or percent. not both.


heres two style for youto see what i mean

Expand|Select|Wrap|Line Numbers
  1. div.container {
  2.     width: 800px;
  3.     margin: 0 auto;
  4.     border: 0px;
  5. }
  6. div.center_content {
  7.     background-color:#0033FF;
  8.     width: 600px;
  9.     float: left;
  10. }
  11. div.left_content {
  12.     background-color:#770000;
  13.     width: 200px;
  14.     float: left;
  15. }
  16. div.right_content {
  17.     background-color:#7733FF;
  18.     width: 200px;
  19.     float: left;
  20. }

Expand|Select|Wrap|Line Numbers
  1. div.container {
  2.     width: 100%;
  3.     margin: 0 auto;
  4.     border: 0px;
  5. }
  6. div.center_content {
  7.     background-color:#0033FF;
  8.     width: 60%;
  9.     float: left;
  10. }
  11. div.left_content {
  12.     background-color:#770000;
  13.     width: 20%;
  14.     float: left;
  15. }
  16. div.right_content {
  17.     background-color:#7733FF;
  18.     width: 20%;
  19.     float: left;
  20. }
Mar 12 '08 #2
TheServant
1,168 Expert 1GB
This guy has done it, but I want to know why you need all the container div's:
Holy Grail 3

His CSS goes like:
Expand|Select|Wrap|Line Numbers
  1. .holygrail {
  2. background:#FFFF99 none repeat scroll 0%;
  3. }
  4. .holygrail .colmid {
  5. background:#FFFFFF none repeat scroll 0%;
  6. float:left;
  7. margin-left:-200px;
  8. position:relative;
  9. right:100%;
  10. width:200%;
  11. }
  12. .holygrail .colleft {
  13. background:#FFD8B7 none repeat scroll 0%;
  14. float:left;
  15. left:400px;
  16. margin-left:-50%;
  17. position:relative;
  18. width:100%;
  19. }
  20. .holygrail .col1wrap {
  21. float:left;
  22. padding-bottom:1em;
  23. position:relative;
  24. right:200px;
  25. width:50%;
  26. }
  27. .holygrail .col1 {
  28. left:200%;
  29. margin:0pt 215px;
  30. overflow:hidden;
  31. position:relative;
  32. }
  33. .holygrail .col2 {
  34. float:right;
  35. position:relative;
  36. right:15px;
  37. width:170px;
  38. }
  39. .holygrail .col3 {
  40. float:right;
  41. left:50%;
  42. margin-right:45px;
  43. position:relative;
  44. width:170px;
  45. }
His html:
[HTML]<div class="colmask holygrail">
<div class="colmid">
<div class="colleft">
<div class="col1wrap">
<div class="col1">
{..code..}
</div>
</div>
<div class="col2">
{..code..}
</div>
<div class="col3">
{..code..}
</div>
</div>
</div>
[/HTML]
Mar 12 '08 #3
drhowarddrfine
7,435 Expert 4TB
Though CSS is the best way to layout a page, when you go for general-purpose and ultimate flexibility, everything must be accounted for. And when you have to include all the "IE fixing", the markup can get pretty big.

iow, a baby's gotta do what a baby's gotta do! (Who can tell me what that line is from?) :)
Mar 12 '08 #4
harshmaul
490 Expert 256MB
sounds like something tommy would say from rugrats.
Mar 12 '08 #5
drhowarddrfine
7,435 Expert 4TB
Your favorite show, too?! :)
Mar 12 '08 #6
TheServant
1,168 Expert 1GB
OK, so all that is necessary. I thought so, but hoped I could find a way to get by the fixes. Thanks for you help guys.
Mar 12 '08 #7
Markus
6,050 Expert 4TB
Your favorite show, too?! :)
I absolutely hated angelica.
Always thwarting tommy n the gangs plans.
>=[
Mar 12 '08 #8

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

Similar topics

0
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as ...
0
by: Shravan | last post by:
Hi, I saw that in Windows Forms DataGrid with new row creation set to true, if I have added a new row earlier which was empty and deleted the row and shifted the focus to any other control and...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
26
by: meltedown | last post by:
I have 2 left floating divs on a page. Sometime the left side is larger, sometimes the right side is larger. I want the page to have a margin at the bottom of whichever div is the largest. If I...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
3
by: jc | last post by:
Hello. I have a gridview column item that i want to not make visible if the bound data in that cell is less than a value in a textbox. However, I notice at the time my code checks a function...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.