|
|
|
|
![]() ![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 378 Joined: 13-October 04 From: Slovenia Member No.: 1,731 |
Post
#1
Aug 1 2005, 09:49 AM
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 IE5 hack were we did center align of everything that is inside of body. Meaning Wrapper will stay in center due the fact, that margin left and margin right – AUTO doesn't aplly for IE5. So this problem is solved. CODE #Wrapper{ width:750px; text-align:left; min-width: 500px; margin:0px auto 0px auto; background:#FFFFFF; } This is code for Wrraper. We used fixed width, margin are set to AUTO left and AUTO right, which will keep your site centered in browsers like Firefox, Opera, IE6.., new browsers actually. Next things that will be defined are Header, Content and Footer. CODE #Header{ width:750px; height:100px; background:#FFFFFF; margin:0px; padding:0px; } In this section we have defined Header properties. Width and height, margins and background. No big fuss. CODE #Content{ width:750px; background:#FFFFFF; margin:0px; padding:10px; } We have defined Content area so that it has 10 pixels of padding at top, meaning that Text will not be touching any borders of Content and will look more compact. CODE #Footer{ width:766px; height:25px; background:#FFFFFF; margin:0px; padding:0px; } Here we have defined Footer, which is 750px of width and 25px of height. No padding, nor margin. CODE p.text{ font:11px/14px verdana, arial, serif; color: #000000; margin:0px; padding:0px 10px 10px 10px; text-align:justify; } This next thing is p.class for text. With classes you can define different styles of text (you are formatting it). Notice the padding-bottom, left and right of 10px. That means you don't have to use paragraph breaker, you just start with new area of same p.class and will show up like you use command break. Padding left and right gives space on left and right side of content. Font is defined as 11px of height with 14px of spacing (around 2px between lines in same paragraph), color is black (#000000). So here we will make a CSS file and HTML file which is gonna be linked to a CSS file. CSS file serves as graphical presentation of our website and HTML builds and renders our actual website. Here is the code of HTML file: 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 fixed width.</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"> <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><!--Content--> <div id="Footer"><p class="text">Footer</p></div><!--Footer--> </div><!--Wrapper--> </body> </html> Here is CSS file (name it layout12.css, cause HTML is linked to this name of CSS file, but you can change it to your needs, but prior change the name of link to CSS file in HTML file): CODE body{ width:100%; margin:0px; padding: 0px; text-align:center; background:#FFFFFF; } #Wrapper{ width:750px; text-align:left; min-width: 500px; margin:0px auto 0px auto; background:#FFFFFF; } #Header{ width:750px; height:100px; background:#B4A6A6; margin:0px; padding:0px; } #Content{ width:750px; background:#D0C9C9; margin:0px; padding:10px 0px 0px 0px; } #Footer{ width:750px; height:25px; background:#BB9999; margin:0px; padding:0px; } p.text{ font:11px/14px verdana, arial, serif; color: #000000; margin:0px; padding:0px 10px 10px 10px; text-align:justify; } Notice: You can change your background colors or you can even change your colors into background images. All you need to do is to change code: CODE background:#code of color e.g. BB9999; for Footer, into code: CODE background:url(images1/layout/content1.jpg) no-repeat; where »images1/layout/content1.jpg« is relative path to your image for footer. You can do all of this for content, header and footer. NO-REPEAT means background is shown only once (for footer or header), whereas content can use command REPEAT-Y where backround is repeated vertically, command REPEAT-X will repeat background horizontally. Working exaple of this tutorial is here. CSS file is available here. Any comments are welcome, maybe I have made some mistakes by myself, so that even I can learn out of this tutorial. Best regards, hope you have enjoyed this tutorial, Robert |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
Post
#2
Aug 1 2005, 10:32 AM
Just a couple of points to make about some of your code: You don't need to specify px (or anything else) if you're using a 0 value, e.g., margin: 0. QUOTE(rvovk @ Aug 1 2005, 07:49 PM) #Wrapper{ margin:0px auto 0px auto; } #Content{ padding:10px 0px 0px 0px; } You also don't need to specify the bottom and left properties of something if they're the same as top and right because B & L automatically inherit those properties. So instead of margin:0px auto 0px auto you can just type margin: 0 auto. In the case of padding:10px 0px 0px 0px, you'd type padding:10px 0 0: the L property takes its value from 0 specified for R, but because you want B to be 0 instead of 10, you have to specify that too. Keep in mind that the order of properties goes clockwise: top, right, bottom and left. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 378 Joined: 13-October 04 From: Slovenia Member No.: 1,731 |
Post
#3
Aug 1 2005, 10:41 AM
Cool, thanx mate. Now even I have learned some pointers. Especially about inherit thing. Never really bother myself with this option. And yes, I forgot to write, when writing margin, padding or other properties, it goes like this: top, right, bottom, left. |
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
9 | noxit | 896 | 21st June 2004 - 08:16 PM Last post by: wassie |
|||
![]() |
22 | -iancovenant- | 1,124 | 9th December 2008 - 06:40 PM Last post by: Echo_of_thunder |
|||
![]() |
21 | Dagoth Nereviar | 1,399 | 11th November 2008 - 03:27 AM Last post by: Ruben |
|||
![]() |
6 | rpgsearcherz | 328 | 8th December 2008 - 12:23 PM Last post by: minimcmonkey |
|||
![]() |
3 | Thunder | 547 | 28th July 2004 - 02:35 AM Last post by: killer |
|||
![]() |
12 | EricDrinkard | 1,662 | 6th August 2004 - 09:29 PM Last post by: Vacant |
|||
![]() |
0 | andyy15 | 534 | 29th July 2004 - 03:59 PM Last post by: andyy15 |
|||
![]() |
1 | Jarek_Gd | 243 | 24th February 2008 - 12:49 PM Last post by: rvalkass |
|||
![]() |
21 | PnOyKiO | 2,218 | 12th September 2004 - 11:04 AM Last post by: dreek |
|||
![]() |
15 | Dehornos | 1,611 | 2nd January 2009 - 09:04 AM Last post by: contactskn |
|||
![]() |
11 | sonesay | 744 | 12th February 2008 - 07:42 PM Last post by: sonesay |
|||
![]() |
19 | Vacant | 1,565 | 26th September 2004 - 10:13 AM Last post by: gotcha41 |
|||
![]() |
8 | djleli | 814 | 28th February 2005 - 04:29 PM Last post by: bjrn |
|||
![]() |
17 | odomike | 1,263 | 27th August 2004 - 06:31 AM Last post by: odomike |
|||
![]() |
2 | encryptedwrath | 115 | 30th October 2008 - 07:18 PM Last post by: encryptedwrath |
|||
|
Open Discussion | Time is now: 9th January 2009 - 03:34 AM |