Home » , » Height Fixer For Blogger

Height Fixer For Blogger

Making the Sidebar and the Post Area to be of Same Height

Some of the simple blogger templates use CSS to set the background color of the sidebar and the main post part.In this case,the heights of these two columns can be different making it look a little awkward.In many cases you may want to make both of these columns of the same height.

If you didn't understand what i am talking of,then i will show you some demos.



Check out the sidebars of both


Blog Without Height Fixing – Link

Blog After Height Fixing – Link



The height adjustment can be done using a very simple javascript code.Actually i had to make something like this for another site of mine.So i thought of sharing this with you guys,

Here is the height fixing script.



<!--Height Fixer Starts-->
&lt;script type=&#39;text/javascript&#39;&gt;
&lt;!--
onload=function() {

var mh = document.getElementById(&#39;main-wrapper&#39;).offsetHeight;
var sh = document.getElementById(&#39;sidebar-wrapper&#39;).offsetHeight;
if(sh&gt;mh) mh=sh;
document.getElementById(&#39;main-wrapper&#39;).style.height = document.getElementById(&#39;sidebar-wrapper&#39;).style.height = mh+ &#39;px&#39;
}
//--&gt;
&lt;/script&gt;
<!--Height Fixer Ends-->



What does this height fixer do?



When the page is fully loaded,this javascript code will get executed(as we have used onload). Now the variable mh will get the value of the height of the div with id main-wrapper.The variable sh will get the value of the height of the div with id sidebar-wrapper,Next we make a check.We check if sh is greater than mh.The greater of these values will be assigned to the variable mh





Now we set the height of both the divs[div with id sidebar-wrapper and the div with id main-wrapper]  as sh pixels. So what does this actually do?? This script checks which of these divs have a larger height and assigns that larger height to both of these divs thus making both of them of equal height.



Where to place this height Fixer Code?



The height fixer code can be placed anywhere in the head section of your template.If you are still confused about where to place the code,then place it just above




</head>



Where else Can i Use this Script?



This script can be used anywhere where you need to adjust the height of two divisions(divs) to be the same.In that case don’t forget to change main-wrapper and sidebar-wrapper in this script with the respective ids of those divs.That means you can use this script to adjust the height of any two columns and make them of same height.



Why is the script having so many complex characters like &lt; &gt; etc?.



This is a parsed javascript.Blogger has problems with normal javascript(you might know this if you have tried to add the adsense code into the template).



Does this work on All Browsers?



This is a a very simple javascript code and it will work on all browsers.



Your comments and suggestions are always welcome.


Source: http://www.bloggerplugins.org/2009/08/height-fixer-for-blogger.html

0 comments :

Post a Comment

 
Play : Agame | Y8 Games | Y3 Games
Copyright © 2011. Blogger Tips And Tricks 2012 - All Rights Reserved

Proudly powered by Blogger