Practical PHP Tutorial - Home Page

Chapter 3


Home Page, first page.
Here is the plan:

  • A column in left side content comprising Logo and Navigation List
  • A right side container that has the page's main content
  • A footer that has immediate links
We are going to use Table Layout to achieve this. You can use relative, fluid or other layouts if you want. But for following the tutorial we are doing table layout. Lets start with the basic html syntax.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My Trading Center</title>
<link href="/styles/style.css" rel="stylesheet" type="text/css">
<script src="/scripts/jquery.js" type="text/javascript"></script>
<script src="/scripts/script.js" type="text/javascript"></script>
</head>
<body>

</body>
</html>
I hope you understand this syntax. Again, if you are not familiar with html, css or js, please learn basics of html, css and come back here. There are plenty of tutorials on web on those topics.

I am going to use a constraint using css that will ensure the content is centered in the page. Create a class in you style.css file with following setup.
.center-it {
width: 1000px;
margin: auto;
}
We can use this on any tag that we want horizontally centered on the screen. Put two div with this class in body.
<div class="center-it" id="main-container"></div>
<div class="center-it" id="div-footer"></div>

The first will be the main-container with menu and page's content. The second div will act as the footer.

Lets finish the main-container and come back to the footer. In the main-container, we are going to have a table layout. (Note: Table layouts are discouraged. The reason I use, it feels more faster way. If you are planning for platform-independent-display then, adapt fluid-layout). Declare a table inside the main-container. The table will be having a single row and two columns.
<table style="width:100%; margin-bottom: 50px;" id="page-holder">
  <tr style="vertical-align: top">
    <td style="width: 250px">
      <div id="div-header"></div>
      <div id="div-category"></div>
    </td>
    <td>
      <div id="div-cpanel"></div>
      <div id="div-menu"></div>
      <div id="div-page"></div>
    </td>
  </tr>
</table>
Line 1: In style, width 100% will fill the table into available area, horizontally; 50 pixel bottom margin will put a space between the main-container and the footer. You can also have a top-margin at footer, instead.
Line 2: First row. The vertical-align: top will ensure the contents start from top of the table, irrespective of the browsers initial value for the rows.
Line 3: First column. The fixed column of size 250 pixels. As I said in the start, this column contains the Logo (id-ed "div-header") and the Navigation List (id-ed "div-category").
Line 7: Second column. The main page's content: The control panel (div-cpanel) for handling the Log In system, second (div-menu) for search menu, and the third(div-page) our page's content.

We will come back to the footer page after we have enough pages(?).

Since this layout is going to be common for all the pages in our website, we are going to split the page into two: header and footer, in the next session.

So far, the code for the home page is as follows.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My Trading Center</title>
<link href="styles/style.css" rel="stylesheet" type="text/css">
<script src="scripts/jquery.js" type="text/javascript"></script>
<script src="scripts/script.js" type="text/javascript"></script>
</head>
<body>
<div class="center-it" id="main-container">
<table style="width:100%; margin-bottom: 50px;" id="page-holder">
  <tr style="vertical-align: top">
    <td style="width: 250px">
      <div id="div-header"></div>
      <div id="div-category"></div>
    </td>
    <td>
      <div id="div-cpanel"></div>
      <div id="div-menu"></div>
      <div id="div-page"></div>
    </td>
  </tr>
</table>
</div>
<div class="center-it" id="div-footer"></div>
</body>
</html>

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database