With me knowing some jquery i kinda fell in (probably a mistake) using it for almost everything.. even positioning elements in the webpage.
I like to make websites that fit every resolution. My screen is a 22'' 1920x1080 screen and so i can see everything in a website, but other people might not have such screen so we need to think about them.
So my min-resolution policy is 1024x768. I don't care if you have to scroll down to see more content, but i do care if you have to scroll horizontally, that just can't happen...
What i do is something like:
CSS:
Code: Select all
#content
{
position: absolute;
top: /*header height so it fits together */;
}
Code: Select all
function Position()
{
$("#content").css("left", $(window).width() / 2 - $("#content").width() / 2); //center the div
}
$(window).resize(function()
{
Position();
});
Btw, i use this when i don't want to specify a width for a div, if i did specified i could just do a margin-left: auto and margin-right: auto and it would be centered.