eXceem

Go Back   eXceem > Websites > Website Discussion

Claim your amazing £1,000 slots booster bonus now!


CSS - How can I add left and right columns?

This is a discussion on CSS - How can I add left and right columns? within the Website Discussion forums, part of the Websites category; So I'm going to rework my web site a bit with this template. I want to add left and right ...

Reply
 
Thread Tools
Old 02-07-09, 06:37 AM   #1
iPod Nano 4GB
 
SgtM's Avatar
 
Join Date: Dec 2008
Location: Ohio
Posts: 249
SgtM has a spectacular aura about

CSS - How can I add left and right columns?


So I'm going to rework my web site a bit with this template. I want to add left and right columns. One for google ads, the other for freebie badges. While I know a little HTML, I'm clueless when it comes to CSS. I managed to get a column inserted early this morning, but it shifted everything else down. Any help at all would be appreciated, even if it's a link to a good tutorial (which I've looked for).
 
Reply With Quote
Old 02-07-09, 06:50 AM   #2
iPod 20gb
 
mattyb's Avatar
 
Join Date: May 2009
Location: Sussex
Posts: 505
mattyb has a spectacular aura about
Create a definition for a column in css like:
#leftcolumn {width:200px; height:200px; float:left;}
#rightcolumn {width:200px; height:200px; float:right;}

Then in your mark up simply:
<div id="leftcolumn>Your content</div>
<div id="rightcolumn>Your content</div>

If that isn't working correctly you'll probably need to contain them within a parent wrapper:
#wrapper {width:600px; height:auto;}

Mark up then becomes:
<div id="wrapper>
<div id="leftcolumn>Your content</div>
<div id="rightcolumn>Your content</div>
</div>

hope that helps.
 
Reply With Quote
Old 02-07-09, 08:38 AM   #3
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,415
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
To add to mattyb's post (and correct his HTML ):

Code:
<style type="text/css">
	#wrapper {width:600px; height:auto;}
	#leftcolumn {width:200px; height:200px; float:left;}
	#rightcolumn {width:200px; height:200px; float:right;}
	.clear {clear: both;}
</style>

<div id="wrapper">
	<div id="leftcolumn">Your content</div>
	<div id="rightcolumn">Your content</div>

	<div class="clear"></div>

	You can now add more content here, undearneath the columns, without needing a new division.
</div>
 
Reply With Quote
Old 02-07-09, 09:32 AM   #4
iPod 20gb
 
mattyb's Avatar
 
Join Date: May 2009
Location: Sussex
Posts: 505
mattyb has a spectacular aura about
well spotted Chigley.
Clear fix is a good addition SgtM
 
Reply With Quote
Old 02-07-09, 09:49 AM   #5
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,415
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
Quote:
Originally Posted by mattyb View Post
well spotted Chigley.
Clear fix is a good addition SgtM
I thought you were calling me sergeant major before I realised that that's the OP
 
Reply With Quote
Old 02-07-09, 12:46 PM   #6
iPod Nano 4GB
 
SgtM's Avatar
 
Join Date: Dec 2008
Location: Ohio
Posts: 249
SgtM has a spectacular aura about
Well, it's closer..

without:


with:


The banners I'm testing with are 200x600, though the final product probably won't be that big. Thanks for helping me with this guys. I really appreciate it.

Some code:
HTML
Code:
<!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>
<title>Free Gifts 4U</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="wrapper">
	<div id="leftcolumn"><img src="images/banner.gif"></div>
	<div id="rightcolumn"><img src="images/banner.gif"></div>
<div class="clear"></div>

<div id="topPanel">
CSS
Code:
/* CSS Document */

body{background:#fff; color:#0F0F0F; font:15px/20px Arial, Helvetica, sans-serif; margin:32px 0 0; padding:0;}
div, ul, h1, h2, h3, li, p, img{margin:0; padding:0;}
ul{list-style-type:none;}

<style type="text/css">
	#wrapper {width:200px; height:auto;}
	#leftcolumn {width:200px; height:600px; float:left;}
	#rightcolumn {width:200px; height:600px; float:right;}
	.clear {clear: both;}
</style>


/* TOP PANEL*/
 
Reply With Quote
Old 02-07-09, 01:49 PM   #7
iPod 20gb
 
mattyb's Avatar
 
Join Date: May 2009
Location: Sussex
Posts: 505
mattyb has a spectacular aura about
Your wrapper will need to be as wide as than the sum of the two columns which need to be as wide as the content you will place within them.
You have the wrapper set as 200px as well as containing two columns each of 200px meaning you're 200 short.
If your content is going to be 600px wide (for example) make that the width of wrapper and then divide the left and right columns accordingly.

Also you don't need this if you're already using a separate style sheet:
<style type="text/css">
...
...
</style>
That's only if it's at the top of an HTML page.
 
Reply With Quote
Old 03-07-09, 07:31 AM   #8
iPod Nano 4GB
 
SgtM's Avatar
 
Join Date: Dec 2008
Location: Ohio
Posts: 249
SgtM has a spectacular aura about
Thanks mattyb. Unfortunately, the columns are pushing everything down now, with the columns appearing only on the left side. It's staying aligned, but it's being pushed down. Anyway, I'm going to rework this, and have images mixed in with text I think. +rep to you and Chigley for jumping in and helping.
 
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off





All times are GMT. The time now is 07:42 AM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts