rob1984
22 Mar 2011, 04:35 PM
Hi, I am fairly new to html and css, I have been learning through designing my own basic layout, which has been going ok till now.
I managed to create a basic 2 column layout which was fine, but when i added a 3rd column things went wrong. Both sidebars are being pushed downwards. The tops of both sidebars are suppose to be in line with the top of the center content area.
I have searched for a solution but havnt had any luck.
This is really frustrating so any help would be much appreciated.
Thanks in advance.
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">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Index</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="url">Website Name</a></h1>
</div>
</div>
<!-- end #header -->
<div id="menu">
<ul>
<li><a href="url">Menu 1</a></li>
<li><a href="url">Menu 2</a></li>
<li><a href="url">Menu 3</a></li>
<li><a href="url">Menu 4</a></li>
<li><a href="url">Menu 5</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="page">
<div id="content">
<div class="post">
<h2 class="title"><a href="url">Post Title</a></h2>
<div class="entry">
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<p>Paragraph 4</p>
<p>Paragraph 5</p>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<!-- end #content -->
<div id="left_sidebar">
<ul>
<li>
<h2>Left Sidebar</h2>
<ul>
<li><a href="url">Link 1</a></li>
<li><a href="url">Link 2</a></li>
<li><a href="url">Link 3</a></li>
<li><a href="url">Link 4</a></li>
<li><a href="url">Link 5</a></li>
</ul>
</li>
</ul>
</div>
<!-- end #left_sidebar -->
<div id="right_sidebar">
<ul>
<li>
<h2>Right Sidebar</h2>
<ul>
<li><a href="url">Link 1</a></li>
<li><a href="url">Link 2</a></li>
<li><a href="url">Link 3</a></li>
<li><a href="url">Link 4</a></li>
<li><a href="url">Link 5</a></li>
</ul>
</li>
</ul>
</div>
<!-- end #right_sidebar -->
<div style="clear: both;"> </div>
</div>
</div>
<!-- end #page -->
<div id="footer">
<p>Footer - (C) Copyright</p>
</div>
<!-- end #footer -->
</body>
</html>
CSS
body {
margin: 0;
padding: 0;
background: #ffffff;
font-family: Arial;
font-size: 12px;
color: #000000;
}
h1, h2, h3 {
margin: 0;
padding: 0;
font-family: Arial;
font-weight: normal;
color: #000000;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.8em;
}
h3 {
font-size: 1.6em;
}
p, ul{
margin-top: 0;
line-height: 180%;
}
a {
text-decoration: none;
color: #000000;
}
a:hover {
}
#wrapper {
width: 95%;
margin: 0 auto;
padding: 0;
}
/* Header */
#header {
width: 95%;
height: 110px;
margin: 0 auto;
}
/* Logo */
#logo {
float: left;
height: 65px;
margin: 0;
padding-top: 20px;
color: #000000;
}
#logo h1 {
margin: 0;
padding: 0;
float: left;
letter-spacing: -1px;
font-size: 4.6em;
color: #000000;
}
#logo a {
border: none;
background: none;
text-decoration: none;
color: #000000;
}
/* Menu */
#menu {
width: 95%;
height: 50px;
margin: 0 auto;
padding: 0;
background: #000000;
}
#menu ul {
margin: 0;
padding: 0px 0px 0px 10px;
list-style: none;
line-height: normal;
}
#menu li {
float: left;
}
#menu a {
display: block;
margin-right: 3px;
height: 35px;
padding: 15px 30px 7px 12px;
text-decoration: none;
font-family: Arial;
font-size: 13px;
font-weight: bold;
color: #FFFFFF;
border: none;
}
#menu a:hover {
text-decoration: underline;
}
/* Page */
#page {
width: 95%;
margin: 0 auto;
padding: 20px 0px 0px 0px;
}
/* Content */
#content {
margin-left: auto;
margin-right: auto;
width: 670px;
padding: 0;
}
.post {
margin-bottom: 25px;
padding: 0px;
background: #FFFFFF;
}
.post .title {
height: 38px;
background: #000000;
padding: 12px 0 0 20px;
letter-spacing: -.5px;
color: #FFFFFF;
}
.post .title a {
border: none;
color: #FFFFFF;
}
.post .entry {
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
padding: 10px 20px 20px 20px;
padding-bottom: 20px;
text-align: justify;
}
/* Left Sidebar */
#left_sidebar {
float: left;
width: 240px;
padding: 0px;
color: #000000;
}
#left_sidebar ul {
padding: 0;
list-style: none;
}
#left_sidebar li {
margin: 0;
padding: 0;
}
#left_sidebar li ul {
margin-bottom: 30px;
padding: 0px 20px 20px 20px;
background: #FFFFFF;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
}
#left_sidebar li li {
line-height: 35px;
border-bottom: 1px dashed #000000;
padding-left: 3px;
}
#left_sidebar li li span {
display: block;
margin-top: -20px;
padding: 0;
font-size: 11px;
font-style: italic;
}
#left_sidebar h2 {
height: 38px;
padding: 12px 0 0 20px;
background: #000000;
letter-spacing: -.5px;
color: #FFFFFF;
}
#left_sidebar p {
margin: 0px 0px 20px 0px;
padding: 10px 20px 20px 20px;
background: #FFFFFF;
text-align: justify;
}
#left_sidebar a {
border: none;
}
#left_sidebar a:hover {
text-decoration: underline;
}
/* Right Sidebar */
#right_sidebar {
float: right;
width: 240px;
padding: 0px;
color: #000000;
}
#right_sidebar ul {
padding: 0;
list-style: none;
}
#right_sidebar li {
margin: 0;
padding: 0;
}
#right_sidebar li ul {
margin-bottom: 30px;
padding: 0px 20px 20px 20px;
background: #FFFFFF;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
}
#right_sidebar li li {
line-height: 35px;
border-bottom: 1px dashed #000000;
padding-left: 3px;
}
#right_sidebar li li span {
display: block;
margin-top: -20px;
padding: 0;
font-size: 11px;
font-style: italic;
}
#right_sidebar h2 {
height: 38px;
padding: 12px 0 0 20px;
background: #000000;
letter-spacing: -.5px;
color: #FFFFFF;
}
#right_sidebar p {
margin: 0px 0px 20px 0px;
padding: 10px 20px 20px 20px;
background: #FFFFFF;
text-align: justify;
}
#right_sidebar a {
border: none;
}
#right_sidebar a:hover {
text-decoration: underline;
}
/* Footer */
#footer {
width: 960px;
height: 64px;
margin: 0 auto;
padding: 0px 0 15px 0;
font-family: Arial;
}
#footer p {
margin: 0;
padding-top: 26px;
line-height: normal;
font-size: 12px;
text-align: center;
color: #000000;
}
#footer a {
font-weight: bold;
color: #000000;
}
I managed to create a basic 2 column layout which was fine, but when i added a 3rd column things went wrong. Both sidebars are being pushed downwards. The tops of both sidebars are suppose to be in line with the top of the center content area.
I have searched for a solution but havnt had any luck.
This is really frustrating so any help would be much appreciated.
Thanks in advance.
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">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Index</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="url">Website Name</a></h1>
</div>
</div>
<!-- end #header -->
<div id="menu">
<ul>
<li><a href="url">Menu 1</a></li>
<li><a href="url">Menu 2</a></li>
<li><a href="url">Menu 3</a></li>
<li><a href="url">Menu 4</a></li>
<li><a href="url">Menu 5</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="page">
<div id="content">
<div class="post">
<h2 class="title"><a href="url">Post Title</a></h2>
<div class="entry">
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<p>Paragraph 4</p>
<p>Paragraph 5</p>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<!-- end #content -->
<div id="left_sidebar">
<ul>
<li>
<h2>Left Sidebar</h2>
<ul>
<li><a href="url">Link 1</a></li>
<li><a href="url">Link 2</a></li>
<li><a href="url">Link 3</a></li>
<li><a href="url">Link 4</a></li>
<li><a href="url">Link 5</a></li>
</ul>
</li>
</ul>
</div>
<!-- end #left_sidebar -->
<div id="right_sidebar">
<ul>
<li>
<h2>Right Sidebar</h2>
<ul>
<li><a href="url">Link 1</a></li>
<li><a href="url">Link 2</a></li>
<li><a href="url">Link 3</a></li>
<li><a href="url">Link 4</a></li>
<li><a href="url">Link 5</a></li>
</ul>
</li>
</ul>
</div>
<!-- end #right_sidebar -->
<div style="clear: both;"> </div>
</div>
</div>
<!-- end #page -->
<div id="footer">
<p>Footer - (C) Copyright</p>
</div>
<!-- end #footer -->
</body>
</html>
CSS
body {
margin: 0;
padding: 0;
background: #ffffff;
font-family: Arial;
font-size: 12px;
color: #000000;
}
h1, h2, h3 {
margin: 0;
padding: 0;
font-family: Arial;
font-weight: normal;
color: #000000;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.8em;
}
h3 {
font-size: 1.6em;
}
p, ul{
margin-top: 0;
line-height: 180%;
}
a {
text-decoration: none;
color: #000000;
}
a:hover {
}
#wrapper {
width: 95%;
margin: 0 auto;
padding: 0;
}
/* Header */
#header {
width: 95%;
height: 110px;
margin: 0 auto;
}
/* Logo */
#logo {
float: left;
height: 65px;
margin: 0;
padding-top: 20px;
color: #000000;
}
#logo h1 {
margin: 0;
padding: 0;
float: left;
letter-spacing: -1px;
font-size: 4.6em;
color: #000000;
}
#logo a {
border: none;
background: none;
text-decoration: none;
color: #000000;
}
/* Menu */
#menu {
width: 95%;
height: 50px;
margin: 0 auto;
padding: 0;
background: #000000;
}
#menu ul {
margin: 0;
padding: 0px 0px 0px 10px;
list-style: none;
line-height: normal;
}
#menu li {
float: left;
}
#menu a {
display: block;
margin-right: 3px;
height: 35px;
padding: 15px 30px 7px 12px;
text-decoration: none;
font-family: Arial;
font-size: 13px;
font-weight: bold;
color: #FFFFFF;
border: none;
}
#menu a:hover {
text-decoration: underline;
}
/* Page */
#page {
width: 95%;
margin: 0 auto;
padding: 20px 0px 0px 0px;
}
/* Content */
#content {
margin-left: auto;
margin-right: auto;
width: 670px;
padding: 0;
}
.post {
margin-bottom: 25px;
padding: 0px;
background: #FFFFFF;
}
.post .title {
height: 38px;
background: #000000;
padding: 12px 0 0 20px;
letter-spacing: -.5px;
color: #FFFFFF;
}
.post .title a {
border: none;
color: #FFFFFF;
}
.post .entry {
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
padding: 10px 20px 20px 20px;
padding-bottom: 20px;
text-align: justify;
}
/* Left Sidebar */
#left_sidebar {
float: left;
width: 240px;
padding: 0px;
color: #000000;
}
#left_sidebar ul {
padding: 0;
list-style: none;
}
#left_sidebar li {
margin: 0;
padding: 0;
}
#left_sidebar li ul {
margin-bottom: 30px;
padding: 0px 20px 20px 20px;
background: #FFFFFF;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
}
#left_sidebar li li {
line-height: 35px;
border-bottom: 1px dashed #000000;
padding-left: 3px;
}
#left_sidebar li li span {
display: block;
margin-top: -20px;
padding: 0;
font-size: 11px;
font-style: italic;
}
#left_sidebar h2 {
height: 38px;
padding: 12px 0 0 20px;
background: #000000;
letter-spacing: -.5px;
color: #FFFFFF;
}
#left_sidebar p {
margin: 0px 0px 20px 0px;
padding: 10px 20px 20px 20px;
background: #FFFFFF;
text-align: justify;
}
#left_sidebar a {
border: none;
}
#left_sidebar a:hover {
text-decoration: underline;
}
/* Right Sidebar */
#right_sidebar {
float: right;
width: 240px;
padding: 0px;
color: #000000;
}
#right_sidebar ul {
padding: 0;
list-style: none;
}
#right_sidebar li {
margin: 0;
padding: 0;
}
#right_sidebar li ul {
margin-bottom: 30px;
padding: 0px 20px 20px 20px;
background: #FFFFFF;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
}
#right_sidebar li li {
line-height: 35px;
border-bottom: 1px dashed #000000;
padding-left: 3px;
}
#right_sidebar li li span {
display: block;
margin-top: -20px;
padding: 0;
font-size: 11px;
font-style: italic;
}
#right_sidebar h2 {
height: 38px;
padding: 12px 0 0 20px;
background: #000000;
letter-spacing: -.5px;
color: #FFFFFF;
}
#right_sidebar p {
margin: 0px 0px 20px 0px;
padding: 10px 20px 20px 20px;
background: #FFFFFF;
text-align: justify;
}
#right_sidebar a {
border: none;
}
#right_sidebar a:hover {
text-decoration: underline;
}
/* Footer */
#footer {
width: 960px;
height: 64px;
margin: 0 auto;
padding: 0px 0 15px 0;
font-family: Arial;
}
#footer p {
margin: 0;
padding-top: 26px;
line-height: normal;
font-size: 12px;
text-align: center;
color: #000000;
}
#footer a {
font-weight: bold;
color: #000000;
}