Solved

CSS - 3 column div layout 2 fixed widths one fluid

Posted on 2007-11-28
5
7,249 Views
Last Modified: 2013-11-19
I having trouble with my CSS.

WHat im trying to do is create a 3 column div layout where the center div uses a width of 100%

The problem im having is that the 3rd column gets pushed to the next line when using a width of 100%
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
   <title>Untitled XHTML Document</title>
<style>
body,html {
   height: 100%;
   padding: 0;
   margin: 0;
   border: 0;
   }
#frame {
   background-color: #000000;
   width: 100%;
   height: 100%;
   }
#col1 {
   background-color: #ff0000;
   width: 200px;
   height: 100%;
   float: left;
   }
#col2 {
   background-color: #0000ff;
   width: 100%;
   height: 100%;
   float: left;
   }
#col3 {
   background-color: #c0c0c0;
   width: 200px;
   height: 100%;
   float: left;
   }
</style>
</head>
<body>
<div id="frame">
 <div id="col1">test</div>
 <div id="col2">test1</div>
 <div id="col3">test2</div>
 <br clear="all" />
</div>
 
</body>
</html>

Open in new window

0
Comment
Question by:Griffin80
[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
5 Comments
 
LVL 19

Expert Comment

by:darron_chapman
ID: 20371326
You need to use wrappers to gain the effect you are trying to achieve.  Perhaps this site can help: http://www.manisheriar.com/holygrail/index.htm.
0
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 20377457
Maybe this is what you want
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
   <title>Untitled XHTML Document</title>
<style>
body,html {
   height: 100%;
   padding: 0;
   margin: 0;
   border: 0;
   }
#col1 {
   background-color: #ff0000;
   width: 200px;
   height: 100%;
   position: absolute;
}
#col2 {
   background-color: #0000ff;
   position: absolute;
   height: 100%;
   left: 200px;
   right: 200px;
   }
#col3 {
   background-color: #c0c0c0;
   width: 200px;
   height: 100%;
   position:absolute;
   right: 0px;
   }
</style>
</head>
<body>
 <div id="col1">test</div>
 <div id="col2">test1</div>
 <div id="col3">test2</div>
</body>
</html>

Open in new window

0
 
LVL 3

Accepted Solution

by:
anandhariharan earned 500 total points
ID: 20491103
Here you go! Hope this solves your problem
<html>
<head>
<style type="text/css">
body{ margin:0px; }
.col1{ width:200px; height:500px; background-color:blue; color:#FFF; float:left; }
.col2{ width:100%; height:500px; background-color:green; color:#FFF; }
.col3{ width:200px; height:500px; background-color:red; color:#FFF; float:right; position:absolute; right:0px; }
</style>
</head>
<body>
<div class="col3">This is a test col 3</div>
<div class="col2">
  <div class="col1">This is a test col 1</div>
  This is a test col 2
</div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:Griffin80
ID: 31411581
Thanks mate
0
 
LVL 3

Expert Comment

by:anandhariharan
ID: 20625382
anytime
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bootstrap wrap text 1 57
Customising IE behaviour on certain pages 2 98
ASP.NET data base connection 35 93
Developers / Staff Setup 10 41
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

732 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