Solved

three column CSS without relative positioning

Posted on 2009-04-06
5
318 Views
Last Modified: 2012-05-06
How can i implement a three column CSS without using relative positioning of the columns.
0
Comment
Question by:Anthony Matovu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:qwerty021600
ID: 24075736
<!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=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body  {
      font: 100% Verdana, Arial, Helvetica, sans-serif;
      background: #666666;
      margin: 0;
      padding: 0;
      text-align: center;
      color: #000000;
}
.thrColAbs #container {
      position: relative;
      width: 780px;  
      background: #FFFFFF;
      margin: 0 auto;
      border: 1px solid #000000;
      text-align: left;
}

.thrColAbs #sidebar1 {
      position: absolute;
      top: 0;
      left: 0;
      width: 150px;
      background: #EBEBEB;
      padding: 15px 10px 15px 20px;
}
.thrColAbs #sidebar2 {
      position: absolute;
      top: 0;
      right: 0;
      width: 160px;
      background: #EBEBEB;
      padding: 15px 10px 15px 20px;
}
.thrColAbs #mainContent {
      margin: 0 200px;
      padding: 0 10px;
}
.fltrt {
      float: right;
      margin-left: 8px;
}
.fltlft {
      float: left;
      margin-right: 8px;
}
-->
</style></head>

<body class="thrColAbs">

<div id="container">
 
  <div id="mainContent">
    <h1> Main Content </h1>
    <p>Column 2</p>
    <!-- end #mainContent --></div>
      <div id="sidebar1">
  <h3>Sidebar1 </h3>
    <p>Column1</p>
    <!-- end #sidebar1 --></div>
  <div id="sidebar2">
    <h3>Sidebar2 </h3>
    <p>Column 3 </p>
  </div>
</div>
</body>
</html>

Try this
0
 
LVL 1

Author Comment

by:Anthony Matovu
ID: 24075854
This works, but what do the two parameters for do (margin: 0 200px;) and is it possible to use percentages instead of absolute and relative.

0
 
LVL 13

Expert Comment

by:qwerty021600
ID: 24075865
Margin is to align the DIV's in proper spacing with each other.
also percentage can be replaced by pixels but not by position.
0
 
LVL 1

Author Comment

by:Anthony Matovu
ID: 24075969
Thanks, I am wondering about the two parameter for margin (0 and 200px) is one left and the other right.  is it also possible to use   (width = 20% for left column, width=60% for midle column, and width = 20% for the right column.
0
 
LVL 13

Accepted Solution

by:
qwerty021600 earned 500 total points
ID: 24076009
<!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=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
<!--
body  {
      font: 100% Verdana, Arial, Helvetica, sans-serif;
      background: #666666;
      margin: 0;
      padding: 0;
      text-align: center;
      color: #000000;
}
.thrColAbs #container {
      position: relative;
      width: 780px;  
      background: #FFFFFF;
      margin: 0 auto;
      border: 1px solid #000000;
      text-align: left;
}

.thrColAbs #sidebar1 {
      position: absolute;
      top: 0;
      left: 0;
      width: 20%;
      background: #EBEBEB;
      padding: 15px 10px 15px 20px;
}
.thrColAbs #sidebar2 {
      position: absolute;
      top: 0;
      right: 0;
      width: 20%;
      background: #EBEBEB;
      padding: 15px 10px 15px 20px;
}
.thrColAbs #mainContent {
      margin: 0 200px;
      padding: 0 10px;
        width: 45%;
}
.fltrt {
      float: right;
      margin-left: 8px;
}
.fltlft {
      float: left;
      margin-right: 8px;
}
-->
</style></head>

<body class="thrColAbs">

<div id="container">
 
  <div id="mainContent">
    <h1> Main Content </h1>
    <p>Column 2</p>
    <!-- end #mainContent --></div>
      <div id="sidebar1">
  <h3>Sidebar1 </h3>
    <p>Column1</p>
    <!-- end #sidebar1 --></div>
  <div id="sidebar2">
    <h3>Sidebar2 </h3>
    <p>Column 3 </p>
  </div>
</div>
</body>
</html>
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create a table with buttons 3 42
Flex Messes  With Horizontal Positioning 2 35
.CSS HTML Help 3 58
Displaying Text in Columns in HTML 3 32
Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question