A new technique to solve div height issue

  By: admin   tags Date Added: Sunday 13-06-2010

If you have not made the switch from the table-design to the tables design, you should now. Even tough that table-less design seems hard to learn, particularly to those who are used to the tabular design it comes with many benefits. The first and the foremost benefit is the great control over the different parts of the website layout. Add to the that most search engines now (i.e Google :) ) favours websites with table-less layout since table layout is considered to be tabular data.

There are two layouts that are used commonly across website “the two columns” (figure 1) and “the three columns” (figure 2) layout. That is the content in the middle and menus on the sides.


Figure 1




Figure 2



The problem:
This layout, when using a table-less layout, comes with a downfall. If the contents container in the middle extends to be more than the side menus bars, the container of the side menus will not extend to the height of the contents. This will affect the appearance of the website. (figure 3)


Figure 3



The first solution that comes to one’s mind is to set the side menus bar’s height to be div {height: 100%}. Nonetheless, this solution is not sufficient since the div container does not have any thing to factor the height. To come over this issue you have to set all the parent containers to 100%.
Another solution is to use Faux Columns. In short this technique sets a background that extends over the contents container and the side menus bars (the author used an example of one side layout, but the concept can be applied to two sides) and then the background is repeated vertically. So the side menu bars will “appear” to be extending down the entire page while in fact it is the background of the contents container.
Even thought this method provides a nice cheat to the issue of div height it limits the designer with the options that he would have in terms of side menus container’s width and background repetition.

The solution:
An extra efficient solution exists, no matter how desperate is the problem. Using div position and stack order one can easily design a website layout that contains extendable side menus bars.

First we set up the layout with the style sheet:
PHP Code


<head>
#main-container {
width: 1000px;
}
#left-side-bar {
float: left;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
}
#contents {
float: left;
font: normal 12px arial, sans-serif;
width: 600px;
background-color: #ddeec8;
}
#right-side-bar {
float: right;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
}
</head>

<body>
<div id="main-container">

<div id="left-side-bar">Side bar text </div>

<div id="contents">Lorem ipsum dolor sit amet </div>

<div id="right-side-bar">Side bar text </div>
<div style="clear:both">
</div>
</body>


Click here to see the layout in example 1.
To make the background stretches vertically to be as high as the longest div container we will create a duplicate of the div containers that we want to extend (with few changes) and their relevant CSS selectors (I will create one for each menu bar in this tutorial, but you can create a duplicate for any container you like).

I will add these selectors to the page head with simple change:
PHP Code

#left-side-bar-bg {
float: left;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
/* add absolute position to this selector*/
position: absolute;
/* add top and bottom margins of the absolute position*/
top: 0;
bottom: 0;
/* since this is the selector for left menus bar we add the left margin */
left: 0;
}
#right-side-bar-bg {
float: right;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
/* add absolute position to this selector*/
position: absolute;
/* add top and bottom margins of the absolute position*/
top: 0;
bottom: 0;
/* since this is the selector for right menus bar we add the right margin */
right: 0;
}


And I will also add these two divs to the page body and within the main-container div:
PHP Code

<div id="left-side-bar-bg"></div>
<div id="right-side-bar-bg"></div>


Click Here to see the end results in example 2.

You probably noticed that in example 2, the div containers that I have created are not extended within the parent div container. To solve this we add:
position: relative;
to the main-container selector. This will tell the browser to extend the new div containers within the main-container div.

Click here to see the new created containers in example 3.

In example 3 we notice that the new div we create are places over the original side menu bars. This were stack order comes in handy. Using z-index propriety we can "order" the div containers stack that we have. The larger the number is the higher the div is. Please note that z-index propriety will not work with "position: static" which is the default positioning of any div container, so we will change the position of the original side menu containers to "relative" in order for them to be ordered correctly.

Now the final CSS will look like this:
PHP Code

#main-container {
width: 1000px;
position: relative;
}
#left-side-bar {
float: left;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
position: relative;
/* set z-index to a high number to keep the container on top of its duplicate */
z-index: 99;
}
#contents {
float: left;
font: normal 12px arial, sans-serif;
width: 600px;
background-color: #ddeec8;

}
#right-side-bar {
float: right;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
position: relative;
/* set z-index to a high number to keep the container on top of its duplicate */
z-index: 99;
}
#left-side-bar-bg {
float: left;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
/* add absolute position to this selector*/
position: absolute;
/* add top and bottom margins of the absolute position*/
top: 0;
bottom: 0;
/* since this is the selector for left menus bar we add the left margin */
left: 0;
/* set z-index to 0 to keep it the container lower than the original one */
z-index: 0;
}
#right-side-bar-bg {
float: right;
font: normal 12px arial, sans-serif;
width: 200px;
background-color: #ddeef6;
/* add absolute position to this selector*/
position: absolute;
/* add top and bottom margins of the absolute position*/
top: 0;
bottom: 0;
/* since this is the selector for right menus bar we add the right margin */
right: 0;
/* set z-index to 0 to keep the container lower than the original one */
z-index: 0;
}


Click here to see full page in example 4.

Using this technique you can even add an image as a background.
Click here to see image background in example 5

I hope this tutorial is useful and help designers overcome the issue of div height.


Tags: div-height, css More details

Early Morning theme for DiY-CMS

  By: admin   tags Date Added: Sunday 13-06-2010

Hi
Here is another converted theme for DiY-CMS. It is light, tabless and can be easily modified or changed.


Here is the theme photo:



and here is the download link:
http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=17


Tags: theme, ealry-morning, designes More details

Twitter theme for DiY-CMS

  By: admin   tags Date Added: Sunday 13-06-2010

Hi
Here is another theme the I have converted to DiY-CMS. This theme resemlbes the famous social network website Twitter. It is suitable for website with perosnal content or blogs. The theme is tabless and can be modified easily.


Here is the theme photo:



and here is the link for the download:
http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=16


Tags: theme, twitter, designes More details

Blootoon theme for diy-cms

  By: admin   tags Date Added: Sunday 13-06-2010

Hi
Here is a new theme for DiY-CMS. I have converted to DiY-CMS due to its nice colors and light desgin. It can be modified easliy throught the style sheet.

here is the theme screenshot:


and here is the link to download the theme:
http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=15


Tags: blootoon, themes, designes, blue More details

New theme for DiY-CMS: sunset

  By: admin   tags Date Added: Wednesday 09-06-2010

hi
I have converted another theme for the cms, it is called sunset. The theme is nice and might suit many websites with different contents.

Here is the photo of the theme:



And you can download it through this link:
http://diy-cms.com/mod.php?mod=download&modfile=view_file&downid=13


Tags: sunset, themes, designes More details

Search Module 1.0

  By: admin   tags Date Added: Wednesday 02-06-2010

Hi
Searching contents is a vital part of any website since it saves a lot of time for the visitor and for the owner of the website. I think one of the most important things that the DiY-CMS was lacking since its launch was the search part. Therefore, I programmed this search module with many options in order to make the search process very effective through any website that is using DiY-CMS.

Visitor can type any number of keywords and select whether he wants to find them all in one post or anyone of the keywords in a post. Visitor can also select where to search, in News, Forums, Downloads sections or in all of them together with the option of searching in the title or the post.

The visitor can also order the search results in Descending or Ascending order. He can also sort the results by date, number of comments, number of readers or the author of the post.

The visitor can also refine the search by choosing the time scope of the search and how many rows to display in each search results page.

Here is a screen shot for the search module index page:


And you can download it through the download area in this website.
http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=12

Additionally, most of the themes that I will convert in the future will contain a search box that will not function correctly unless this module is installed in your website. (You still can remove the search box from the theme if you do not want to provide search functionality in your website).


Tags: search, modules, updates More details

Happeniss theme for DiY-CMS

  By: admin   tags Date Added: Monday 31-05-2010

Hi
This is a new theme for DiY-CMS. It is a very nice and light theme. In order for it to work correctly you have to update the templates.class file through the update section in your admin area. The theme includes new feature that was not originally integrated into the CMS, thus the file update.

Here is an image of the homepage of the theme:


As you can see in the image to the right, a "rope" is coming from above the sky to hold the menus. The first menu that connects to the rope has a special template, the final one has a special template and the middle menus have a special template as well. You have to select the right template for each menu in order for it to work correctly.

For any assistance with the theme please post your question here or (preferably) at the support forums.

To download the theme:
Click Here


Tags: themes, designs, happeniss More details

New theme "Agriculture"

  By: admin   tags Date Added: Monday 24-05-2010

Hi
This is a new theme for DiY-CMS. The theme is not originally my design, but I have made some modifications on it so it suits DiY-CMS. As you can seen in the photo and as probably the name suggests, that its main color is green. It comes with two styles for menus and you can use either one for your menus. (Please refer to the tutorial on menus management in this blog or in my YouTube channel).

Here is the photo:


To download the theme, click here.

Please post any feedback or suggestions you might have on this theme.


Tags: agriculture, themes, designs More details

Coffee lovers theme

  By: admin   tags Date Added: Monday 24-05-2010

Hi
This is a new theme for DiY-CMS. I should mention that it is not my desing but I modfied it to suit DiY-CMS. It gave me a hard time figuring out how to view it accuratly on IE. Needless to say I did not have any problem viewing it on FF at all.

Here is the theme photo:

and you can download it through the download area by clicking here


Please give me any feedback on the style itself or any general advice. I hope you like it.


Tags: themes, coffee-lovers, designs More details

Notepad Chaos theme for DiY-CMS

  By: admin   tags Date Added: Sunday 16-05-2010

Hi
As promised in the last blog, here is the popular notepad chaos theme. I have made many modification on it to make it work on DiY-CMS. It is very neat and nice theme and the main layout is tabeless. I hope you like it.

Theme's screenshot:



To download the theme:
Click Here


Tags: notepad-chaos, themes, designs More details


 Pages 
« < 1
 2  
3 > »