Creating a Three Page Floated Column

Hi All

I am trying to create a three column layout and have so far been unable to do so.I’ve tried altering the widths of the left and right columns but that didn’t seem to work. :confused:

Below is my html and css code.

<%@ Master Language=“VB” CodeFile=“MasterPage.master.vb” Inherits=“MasterPage” %>

<!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 id=“Head1” runat=“server”><link href=“App_Themes/Stylesheet2.css” rel=“Stylesheet” />
<title>Extra-Time Website The Public Facing Page</title>

</head>
<body>
<form id=“form1” runat=“server”>
<div class=“container”>

	&lt;!--Site Header--&gt;
	&lt;asp:Image ID="Image1" ImageUrl="~/Archive/Images/TitleWide.jpg" AlternateText="Site Header" runat="server" /&gt;

	
  &lt;!--Code for tabstrip and breadcrumb trail--&gt; 
            &lt;div class="tabstrip"&gt;
	&lt;br /&gt;
	&lt;asp:ContentPlaceholder
	ID="ContentPlaceholder1"
	runat="server" /&gt;
	
	 &lt;asp:ContentPlaceholder 
	 ID="ContentPlaceholder2" 
	 runat="server" /&gt;


		&lt;div id="leftside; width=20%;"&gt;
			&lt;h2&gt;Left Hand Navigation Menu&lt;/h2&gt;
		&lt;p&gt;
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer cursus eros et ligula porttitor scelerisque. Mauris eget lorem quis ante pharetra semper. Quisque sed nibh at neque faucibus vestibulum.
			&lt;/p&gt;
			&lt;p&gt;
				Nulla interdum nunc turpis, sit amet sollicitudin libero. Donec at erat vitae nibh molestie ullamcorper quis ac sem. Mauris eu sodales massa. Mauris turpis neque, gravida ac scelerisque non, consectetur quis dolor.
			&lt;/p&gt;
			&lt;p&gt;
				Duis eget velit at turpis consectetur vulputate. Nam dui massa, eleifend id commodo sed; rhoncus vitae velit. Donec elementum tristique magna at dignissim.
			&lt;/p&gt;
		&lt;/div&gt;
		
			&lt;asp:ContentPlaceholder
		 ID="ContentPlaceholder3"
		runat="server" /&gt;
		&lt;div id="rightside"&gt;
	
		
			&lt;h2&gt;Latest News and Featured Products&lt;/h2&gt;
			&lt;p&gt;
				Proin pretium tempus turpis non faucibus. Nullam venenatis, purus euismod sagittis pulvinar, metus elit sodales odio, id consectetur lorem est sed leo. Vivamus vehicula, diam sed congue ullamcorper, libero lorem ullamcorper arcu, ut pulvinar nunc erat vel felis. In gravida tincidunt ante sit amet ullamcorper. Vestibulum ullamcorper blandit nibh vel commodo.
			&lt;/p&gt;
			&lt;p&gt;
				Nam metus enim, accumsan non posuere quis, condimentum in felis. Ut vestibulum enim vitae mauris pharetra non congue erat rhoncus. Phasellus in sagittis quam.
			&lt;/p&gt;
		&lt;/div&gt;
		&lt;!-- Notice the centre column comes last --&gt;
		&lt;!-- This is because only content occuring AFTER a float will lie adjacent to the float --&gt;
		&lt;!-- So, we need to make sure that the centre column occurs AFTER the LEFT and RIGHT columns --&gt;
		&nbsp;&lt;asp:ContentPlaceholder
		 id="ContentPlaceholder4"
		 runat="server"/&gt;
		 
		&lt;div id="midfield"&gt;
		
			&lt;h2&gt;Main Content&lt;/h2&gt;
			&lt;p&gt;
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer cursus eros et ligula porttitor scelerisque. Mauris eget lorem quis ante pharetra semper. Quisque sed nibh at neque faucibus vestibulum. Nulla interdum nunc turpis, sit amet sollicitudin libero. Donec at erat vitae nibh molestie ullamcorper quis ac sem. Mauris eu sodales massa. Mauris turpis neque, gravida ac scelerisque non, consectetur quis dolor. Duis eget velit at turpis consectetur vulputate.
			&lt;/p&gt;
			&lt;p&gt;
				Nam dui massa, eleifend id commodo sed; rhoncus vitae velit. Donec elementum tristique magna at dignissim. Aliquam auctor posuere vulputate. Donec fringilla elit in magna sollicitudin vel consectetur lacus dignissim. Nulla vitae mi vel mi pulvinar pellentesque venenatis et nunc. Fusce adipiscing ultricies facilisis. Pellentesque convallis varius purus at placerat? Integer placerat felis quis felis pretium laoreet tempus nibh adipiscing. Etiam eu ipsum metus! Pellentesque facilisis aliquam dui, non sodales mi accumsan et. Sed velit urna, tempus in euismod eget, ullamcorper vel erat.
			&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/form&gt;

</body>
</html>

CSS Code

body {
}
/* The ‘*’ selector is a wild card. /
/
Used on it’s own like this it means ‘Target all elements’ /
/
Have done this here to zero margin, padding, outline and border for ALL elements for convenience */
*
{
margin:0;
padding:0;
outline:none;
border:none;
}

/* This following rule ensures there is allways a vertical scrollbar /
/
Preventing the annoying ‘jog right’ when moving to a page shorter than sceren height */
html
{
overflow-y:scroll;
}

body
{
font-family:“Lucida Sans Unicode”, “Lucida Grande”, sans-serif;
font-size:12px;
}

h1
{
margin-top:1em;
text-align:center;
text-shadow:0 0 2px #00f;
}

p
{

margin:1em;
padding:0em;
border:none;

text-align:justify;
text-shadow:0 0 1px #090;

}

.container
{
width:900px;
margin:2em auto;
padding:1em;

overflow:auto; /*fixes height when we have floating children */

background:#CCC;
text-align:center;

}

.tabstrip
{
border-top:solid 1px #ffffff;
border-bottom:solid 1px #ffffff;
}

.midfield
{
width:48%;
height:41em;
padding:1%;
background-repeat:repeat-y;
background-color:#000000;
color:#FFFFFF;
text-align:center;
border:1px solid #aaa;
}

.leftwing
{
float:left;
width:20%;
}

.rightwing
{
float:right;
width:20%;
}

Any help would be greatly appreciated.

Try something like

<div id=“leftside”>…content…</div>
<div id=“middle”>…content…<div>
<div id=“rightside”>…content…</div>

#container {margin-left: auto; margin-right: auto; width: 900px; }
#leftside { float: left; width: 180px; padding: 10px; }
#middle { float: left; width: 400px; padding: 10px; }
#rightside {float: left; width: 260px; padding: 10px; }

adjust widths and padding to suit container width

Hi,
The “html” you posted isn’t HTML, it’s VB mixed with HTML. When posting HTML, you should post what the browser shows when you View Source.

Second, wrap your code in [code] tags.


somewhat easier to read

Third, wrapping your entire web page in a form is a bad idea. I know it’s done automatically, but your web page is not a form, and you will not be allowed to add a form to any web page of yours because forms may not be nested.

<div id=“leftside; width=20%;”>
That isn’t legal or valid… if that’s trying to style your widths, it might be why your layout isn’t working, because inline styles like that will try to override CSS in either <style> tags or in external linked stylesheets.


*
{
margin:0;
padding:0;
outline:none;
border:none;
}

generally a bad idea: outline is an accessibility setting which 99% of the time should be left on. * incurs a heavy penalty on browsers, and while I and many other web devs do use it, I only use it for margins, not a large list of properties. Only two tags are going to appear with borders: images and fieldsets (other elements like objects and frames may also have borders but they are less commonly used), so just list them
img, fieldset {
border: 0;
}
tho most fieldsets I keep the border on.

Beyond that, your basic basic setup seems like it should work (floated sidebars first, then middle content).

If you don’t care if the middle part comes first in source, you can keep this basic setup, but I would
-switch to a strict doctype (why not? it only helps the validator show you bad deprecated old-fashioned tags that went the way of spats so long ago but were never as cool)
-clean up validation errors (send your HTML output to the W3C validator and clean up the errors there, including the inline styles)

Then give each of your three main boxes (and the container too) an ugly background colour, so you can see them. If one box is sitting under the other boxes, you’ll be able to see how wide it is.
Because your container is set-width in pixels, I would NOT set the boxes inside with %, esp not with % padding (even if very small). When you are floating boxes, if anyone is a hair too wide, they will drop (float drop).

We can help further with the CSS after those things are changed.

well if the layout is not fluid i don’t think a column width in precentage is the best choice. Main container with the width like sum of columns width and every column floated left. And for background maybe a fake image on main.