Solved

three column CSS without relative positioning

Posted on 2009-04-06
5
326 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

632 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