Centered Website With Two Columns - CSS

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #12) by rvovk on Aug 5 2005, 09:45 AM. (Line Breaks Removed)
I will stay loyal to Trap17 even tho I also have hosting at Computinghost.com. This is a place I like to stay
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Tutorials

Centered Website With Two Columns - CSS

rvovk
This is upgrade of my first tutorial for Centered website with fixed width. Today I am going to present you tutorial for making two columns website with fixed width. My basic tutorial can be found here: here.

So let's begin:

First we will change CSS file, everything stays same if not mentioned to change, starting with color of content from basic tutorial, change background to this code. This will actually be background of left column and padding will be set to 0, cause it will be defined in Left and Right column. New code for Content:

CODE
#Content{
 width:750px;
background:#BEB8B8;
margin:0;
padding:0;
}


Oki. Next thing that we will do is definition of Left column. We will float it to left. Float means there is still space on opposite side.

In our case this is 750px – 150px = 600px of free space on opposite side. Will be needed for Right column.

It will be 150 pixels of width. Height will depend on left or right column, so there is no need to define this. Color for Left column is defined in Content, so here we use code: background: none; . Padding is taken from first tutorial and it is same as it was before for Content:

Code for Left Column:

CODE
#Left{
float:left;
 width:150px;
background:none;
margin:0px;
padding:10px 0px 0px 0px;
}


Now we will define Right column. Width will be by calculation 600px. Padding same as for Left column. No big fuss at all. It is floated to right with code: float:right; . Color of Right column is defined in this properties.

Code for Right column is:

CODE
#Right{
float:right;
 width:600px;
background:#D0C9C9;
margin:0px;
padding:10px 0px 0px 0px;
}


Next thing that we need is named CLEAR – FLOAT. This is a hack actually. There are many version of it over the net. I have started to use this one, which gives me best result in every browser. What this hack does? Float makes your site to collapse if you woudn't use this hack. I removed Left column here for better representation of this collapse. We see that footer has gone up to the header like there wasn't any Content (due to float property).

user posted image

So basicly what we do is:

1. Floatcontainer is container that will prevent collapse.
2. Left coloumn text inside end of Left column.
3. Right coloumn text inside end of Right column.
4. end of Floatcontainer column.

Here is code for HTML file, take a look how is content built now. But firstly remember my 1,2,3,4 points that are explained in a paragraph before:

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Centered website with two columns.</title>
<meta http-equiv="content-type" content="text/html;charset=windows-1250"/>
<style type="text/css" media="all">@import "layout12.css";</style>
</head>

<body>
<div id="Wrapper">
<div id="Header"><p class="text">Header</p></div><!--Header-->
<div id="Content">
<div class="floatcontainer">
<div id="Left">
<p class="text">Link 1</p>
<p class="text">Link 2</p>
<p class="text">Link 3</p>
<p class="text">Link 4</p>
<p class="text">Link 5</p>
<p class="text">Link 6</p>
</div><!--Left-->
<div id="Right">
<p class="text">Things in the future have changed dramatically.
I bought Canon A40 in year 2002 and took several interesting pictures with it.
Later I bought Sony DSC S-75 cause I liked its macro potencial.
But I sold it quickly cause it had lot of noise in images and awful white balance.
Just before end of year 2003 I bought myself second hand Canon G3 which I am still using.
Canon G3 is very good prosumer camera with pleasant results.</p>
<p class="text">Things in the future have changed dramatically.
I bought Canon A40 in year 2002 and took several interesting pictures with it.
Later I bought Sony DSC S-75 cause I liked its macro potencial.
But I sold it quickly cause it had lot of noise in images and awful white balance.
Just before end of year 2003 I bought myself second hand Canon G3 which I am still using.
Canon G3 is very good prosumer camera with pleasant results.</p>
<p class="text">Things in the future have changed dramatically.
I bought Canon A40 in year 2002 and took several interesting pictures with it.
Later I bought Sony DSC S-75 cause I liked its macro potencial.
But I sold it quickly cause it had lot of noise in images and awful white balance.
Just before end of year 2003 I bought myself second hand Canon G3 which I am still using.
Canon G3 is very good prosumer camera with pleasant results.</p>
</div><!--Right-->
</div><!--Float-->
</div><!--Content-->
<div id="Footer"><p class="text">Footer</p></div><!--Footer-->


</div><!--Wrapper-->


</body>
</html>


Working example and source available: here.
CSS file is available: here.
Any suggestions to make this script better is welcome. Script is checked in Firefox, Opera and Internet Explorer. Enjoy.
Robert

 

 

 


Reply

biscuitrat
Very nicely done! Be sure to build off of this for other CSS tutorials if you make any smile.gif

Reply

rvovk
Sure, that was idea in the first place. I am glad you like it.

Reply

FLaKes
Thank you, Thank you soooo much..! I had been lookin for something like this for quite a while but I somehow couldnt find it, and when I did it on trial and error and could not get it to work I would get all frustrated. It was worse when I would preview it on the internet explorer and it would look fine, but when I checked it on firefox the left columns background would appear until the text or content ended. Though I did find some other solutions none where as good as this one. So muchas gracias for this tutorial.

Reply

rvovk
Flakes gave me few thoughts to think over. First solution would give us problem if right column became smaller than left column. So what will do is draw repeater image in Photoshop with 150px Left column of BEB8B8 color, and 600px Right column of D0C9C9 color.

This looks like this:

user posted image

This will give us repeated background in whole content. We must link this image to Content background, so replace this code for Content:

CODE
#Content{
 width:750px;
background:url(repeater.jpg) repeat-y;
margin:0;
padding:0;
}


We must define new background for Right column, so we define background:none. Code is:

CODE
#Right{
float:right;
 width:600px;
background:none;
margin:0px;
padding:10px 0px 0px 0px;
}


New fixed CSS file is available: here.

New fixed site is available: here.

If there would be change in width of Left or Right column, them we must change background repeater image in photoshop to desired width and color.

Robert

 

 

 


Reply

Becca
Whats the different between using tables? Because it can be a fixed with aswell and have two columns.
Anyways good simple-to-follow tutorial : well done.

Reply

rvovk
Becca, to be honest I don't know. It is this thing, when you start doing one thing and you learn alot, then you just keep doing and upgrading on this one. I guess tables are popular if you are doing "tables", like if you were working in Excel with lot of data. CSS is used if you wanna have grapchical approach, you do layout in Photoshop, slice it up to Header, Content which is repeated and Footer.

Reply

biscuitrat
I just prefer div layers to tables now, I guess. It's not like you can't use tables ever again - it's just a better way to go about inserting content.

Reply

Saint_Michael
i have to agree doing div tags has alot more customization to it then regular tables, but yeah you can do alot with justa simple layout like rvovk just proved.

Reply

BlaqueMajik
Nice tutorial, I will have to implement this into my new website maybe. I am not a big buff of much css though. I usually just use tables with repeating backgrounds.

You and a bunch of other people should really think of submitting some of you tutorials to like Pixel2life or some place like that.

Reply

Latest Entries

rvovk
I will stay loyal ph34r.gif to Trap17 even tho I also have hosting at Computinghost.com. This is a place I like to stay wink.gif

Reply

Saint_Michael
yeah pixel2life is good place to have your tutorial placed at but you got alot of compitition there to deal with and also they do alot of deleting of tutorials too.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. hack the canon a40 - 1114.51 hr back. (1)
Similar Topics

Keywords : centered, website, columns, css

  1. My First Website
    Where can i find useful web page templates? (3)
  2. How To Setup A Website After Your Forum
    (3)
    This tutorial is about how to setup a website after you have setup a forum. That means, you have a
    forum, and are wanting to add a website. This tutorial will show you how to create the website in
    your root directory(Example: http://domainname.com) , while your traffic gets redirected to your
    forum while you are creating it, until you're ready for guests to see it. This method is
    opposed to setting it up in another directory, then moving it(particularly more time consuming if
    you're site is PHP based). First of all, you are going to want to setup a redirect ....
  3. Creating Navigation For Html Websites
    Have a common navigation menu for the whole website! (12)
    Pre-requisite: HTML, inline frame tags 1 Attachment(.zip) included. Updates : 29-12-07: Doctype
    added in example files (Advised by jlhaslip) Designing a whole website takes a lot of planning
    and organization. Designing a proper navigation system is a basic step in building your website. If
    you are developing webpages in html you would have observed that as you go on creating pages it
    becomes difficult to maintain the links to the pages. This article will guide you in developing a
    common navigation menu for your website. It describes three ways, so if you don'....
  4. Css Scroll Bar Styles
    Change the color of your website scrollbar! (1)
    REQUIREMENTS 1. Must have limited to good knowledge of CSS. 2. Must have limited to good knowlege
    of HTML. THE ELEMENTS First of all, there are 7 different elements of a scrollbar. a) Scrollbar
    Arrow Color /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />
    Scrollbar Darkshadow Color c) Scrollbar Track Color d) Scrollbar Face Color e) Scrollbar Shadow
    Color f) Scrollbar Highlight Color g) Scrollbar 3dlight Color Bassically all that you need to do is
    change the colors like you normally do with any sort of CSS. Therefore, if you want the....
  5. Making A One Page Does All Website In Phph
    (2)
    Hello and Great Day or Night either one. Have you ever been to a site and seen a index page or any
    page at all control everything such as index.php?do=home&action=logout something similar to the
    above? Well I am going to show you how easy it is to make this all own your own, and only have to
    use one web template or design to make it work. Before we get started you need to go ahead and find
    the web design that you want to use. After you find the site you want to use go ahead and save
    it... and save it like this so we can work together, ok! Note* We are going to ....
  6. Adding Your Website To Google
    How to register with google (25)
    Hi everyone. Hopefully here im going to tell you how to register yourself with the Google search
    engine and get yourself in their results. Ill start the tutorial assuming you already have Meta
    tags or other search engine optimisation techniques in place. This tutorial is solely about
    registering with google. At one time i thought simply using meta tags etcetera would get you listed
    in Google, i then found out that didnt work, so i wondered why, and the fruits of my labour are what
    will go into this tutorial. the first step is to get a google account, this will get y....
  7. Checking Dns Settings For Website
    DNS Setting, Ping, Whois, Dnsreport etc (2)
    If you have recently purchased a domain and facing problems with the workings, the first thing which
    you should check is the DNS setting. Dns settings determine, how to domain is pointed to the Server
    and How the server is connected to the world (internet). Ensure, the DNS settings are perfect to
    make sure, things work smoothly and people across the globe don't have problems accessing your
    site. The basic check would be : PING Suppose you register your domain (example.com) at
    ComputingHost. You get an IP for your website. In this case, suppose its 64.69.35.170. Yo....
  8. Configuring Dns Settings For Website
    Nameserver, A-Address, DNS configuration (1)
    Most of the people have problems configuring their website. After registering their domain, many get
    confused in configuring their domain (basically the DNS settings). This small tutorial will help you
    get started with DNS settings configuration. A domain can be basically pointed to a server using 2
    main techniques. 1. Nameserver (the most recommended way) 2. A Address (Not recommended)
    Configuring using Nameservers ==================== Login to your domain Control panel provided by
    your DOMAIN NAME PROVIDER / REGISTRAR. Not your webhost. Search for settings like DN....
  9. Introduction To Templating
    Templating your website with PHP (1)
    Pre-note Hello and welcome. if your website doesn't use a templating function, you may have
    noticed it's pretty hard to update your website (layout) unless you dig through many files to
    update the images and such. The solution is templates. If you ever got curious and looked into
    phpBB codes or any other template based forum/CMS, you saw the .tpl files they use. I am not at a
    point where i base everything on .tpl (simply because i havent taken the time to see how it all
    works). But i do can tell you that it's the same principle, template your site using an....
  10. Centered Website With Fixed Width
    ...begginers lesson... (2)
    This will be tutorial on how to make a simple website design with fixed width and center position.
    This is actually rather simple tutorial, but hopefully it will help others that are new in world of
    creating websites. Website will also contain header, content area and footer. First we must do
    Wrapper. Wrapper is actually an area of fixed width and will be position into center, so that our
    page doesn't fall apart. CODE body{ width:100%;  margin:0px;  padding:
    0px;  text-align:center; background:#FFFFFF; } This is actually an IE....
  11. Secure The Email Addresses On Your Website!
    Wonderful script and useful! And working (10)
    Just follow the instructions below: /* Secure Email Function by Juan Karlo Aquino de
    Guzman Website: http://www.karlo.ph.tc and http://www.abs-cbn.ph.tc E-mail:
    http://www.karlo.ph.tc/send.php Usage: showEmail("support@microsoft.com",0); OR
    showEmail("support@microsoft.com",1); Types: 0 = ordinary random 1 = more secure random To
    include to a script: include_once("email_secure.php"); */ And here is the code :
    CODE <?php /*     Secure Email Function by Juan Karlo Aquino de Guzman     Website:
    http://www.karlo.....
  12. E-mail Mailer Script 0.1
    useful for website visitors (4)
    Are you pissed off when you are putting e-mail in your website, you always get spammers? Well,
    here's the solution. Just change the default variables to anything that you like, etc... follow
    the instructions on the script.. Here it is... hope you like it /smile.gif' border='0'
    style='vertical-align:middle' alt='smile.gif' /> CODE <?php //E-mail Mailer Script 0.1
    by Juan Karlo de Guzman //FOR TRAP17 ONLY... DEMO VERSION... DO NOT DISTRIBUTE
    header("Content-type: text/html; CHARSET=UTF-8");
    $int_rand=mt_rand(1,20); if&#....
  13. Making A Website
    Also Some Dos and Don'ts (6)
    I had originally had this posted on my domain at nevernormal.com, and thought that you guys could
    use it here as well. Granted, this is geared to the uber newbie, so don't razz me if I
    don't suggest the most advanced in web design. lol So, you want to make a website? 1.
    First, think about what you want your site to be about. There are fanfic sites, like Drastic
    Measures and fanfiction.net ; cliques or clubs, like the BtVS Writers' Guild ; or, if you
    want, you could have a general site, whether it be about a show/movie you like, or even just about y....
  14. [tutorial] Skinning Your Site
    a tutorial on how to skin your website (2)
    For this tutorial you are going to need to know how to use php includes. You are also going to need
    to rename all o your files to a .php extension. In your FTP or Cpanel make a folder in your public
    (main) directory and name it "skins". In the skins folder make another folder named "1". In the
    folder you names skins make a file called cookiecheck.php. Copy the code below and paste it into the
    cookiecheck.php file. $total_skins = 1; $default_skin = 1; if (isset($_REQUEST
    )) { $newskin=(int)$_REQUEST ; if ( ($newskin $t....

    1. Looking for centered, website, columns, css

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for centered, website, columns, css

*MORE FROM TRAP17.COM*
advertisement



Centered Website With Two Columns - CSS



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE