Results 1 to 2 of 2

Thread: Trouble aligning columns in css layout

  1. #1
    Join Date
    Mar 2011
    Location
    London
    Posts
    1

    Trouble aligning columns in css layout

    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


    Code:
    <!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;">&nbsp;</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;">&nbsp;</div>
    		</div>
    	</div>
    	<!-- end #page -->
    	<div id="footer">
    		<p>Footer - (C) Copyright</p>
    	</div>
    	<!-- end #footer -->
    </body>
    </html>
    CSS

    Code:
    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;
    }

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    Your main containers are width: 95%; but your divs inside are in px so they won't fit unless the window resolution is wide enough.

    If you want a fluid width, all elements must have % width including side margins and side padding and images, all totaling 100% (100% of the 95% containers). If you have side borders, these can't be sized in % so you have to make the other items total 97% or 98% to allow for the side borders in px.
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Similar Threads

  1. CSS Drop Shadows for Columns Help
    By Benny-182 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 31 Oct 2007, 04:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •