I am using jquery to dynamically place content based on screen resolution. If the resolution is below 800px in width I want to adjust the elements as necessary but when the window is resized above 800px in width I want the css styles that are already defined in by external css file to be applied to the elements again. I can go through and change everything back again manually but it seems redundant. Is there an object oriented css trick or jquery function that I could use to do this?
Example
$(window).resize(function()
{
if(this.resizeTO)
clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function()
{
if(window.innerWidth < 800)
{
$("#usernameDisplay").css({top: "50px", right:"50%", "margin-right": "-" + $("#usernameDisplay").width()/2 + "px", "padding-top":"0px"});
$("#headerBack").css("height", "95px");
$("#userMenuContainer").css({top: "95px", right:"50%", "margin-right": "-" + $("#userMenuContainer").width()/2 + "px"});
}
else
{
$("#usernameDisplay").css({top: "0px", right:"0", "margin-right": "0", "padding-top":"10px"});
$("#headerBack").css("height", "55px");
$("#userMenuContainer").css({top: "110px", right:"0", "margin-right": "0"});
}
}, 200);
});