1 reply [Last post]
Grafula
Grafula's picture
Offline
newbie
Last seen: 10 years 47 weeks ago
Timezone: GMT+8
Joined: 2012-03-11
Posts: 3
Points: 5

Hi,

I want to create a page with a header, a left navigation column, a center column,a right nav column and a footer.

In the center column I want a sub header and 2 columns side by side. Each of these two columns should take 50% of the center column.

The problem is that the blue column is not next to the red one, but below and to the right of it. They kinda overlap.

Here is the stylesheet I made (the colors are just for orientation...):

body{
	background-color: #000a55;
}
#container
{
width: 90%;
margin: 10px auto;
background-color: #fff;
color: #333;
}
#header
{
padding: .5em;
background-color: #004778;
}
#leftpane
{
float: left;
width: 220px;
text-align: center;
background-color: olive;
}
#rightpane
{
float: right;
width: 220px;
text-align: center;
background-color: #ff8c00;
}
#centerpane
{
margin-left: 240px;
margin-right: 240px;
background-color: #66cdaa;
}
#centerpaneleft
{
padding: 1em;
width: 50%;
float: left;
background-color: red;
}
#centerpaneright
{
padding: 1em;
width: 50%;
float: right;
background-color: blue;
}
#footer
{
clear: both;
padding: .5em;
color: #333;
background-color: #ddd;
}

and here the html:

<!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" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Title</title>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<div id="container">
	<div id="header">
		<h1>Header</h1>
	</div>
	<div id="leftpane">
		<p>leftpane: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut.</p>
	</div>
	<div id="rightpane">
		<p>rightpane: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut.</p>
	</div>
	<div id="centerpane">
		<h2>Subheading</h2>
		<div id="centerpaneleft">
			<p>centerpaneleft: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
		</div>
		<div id="centerpaneright">
			<p>centerpaneright: Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
		</div>
	</div>
	<div id="footer">
		<h1>Footer</h1>
	</div>
</div>
</body>
</html>

Thanks

balajidesign
balajidesign's picture
Offline
Enthusiast
Last seen: 9 years 16 weeks ago
Timezone: GMT+5.5
Joined: 2012-01-31
Posts: 116
Points: 124

Hi grafula, padding should

Hi grafula,

padding should come inside the element. so remove the padding in your code. it will working fine. use the below code:

#centerpaneleft
{
width: 50%;
float: left;
background-color: red;
}
#centerpaneright
{
 
width: 50%;
float: right;
background-color: blue;
}