Skip to content

Instantly share code, notes, and snippets.

@fael
Created September 12, 2011 20:59
Show Gist options
  • Save fael/1212402 to your computer and use it in GitHub Desktop.
Save fael/1212402 to your computer and use it in GitHub Desktop.
Identificar Resolução
var identificarResolucao = function() {
resolucao = "res" + screen.width;
areaVisivel = $("body").width();
//$("#componente").prepend("<br>"+ resolucao);
classe = 'res';
if (areaVisivel < 800) classe += '800';
else if (areaVisivel < 960) classe += '960';
else if (areaVisivel < 1024) classe += '1024';
else if (areaVisivel < 1088) classe += '1088';
else if (areaVisivel < 1152) classe += '1152';
else if (areaVisivel < 1280) classe += '1280';
else if (areaVisivel < 1360) classe += '1360';
else if (areaVisivel < 1440) classe += '1440';
else if (areaVisivel < 1600) classe += '1600';
else if (areaVisivel < 1680) classe += '1680';
classes = $("body").attr("class");
_classes = classes.split(" ");
for (var c in _classes) {
removerClasse(c);
}
function removerClasse(c) {
$("body").removeClass(c);
}
$("body").addClass(classe);
/* -------------------------------------------
RESOLUÇÃO -> ÁREA VISÍVEL (CHROME)
1920 -> ?
1680 -> ?
1600 -> ?
1440 -> 1423
1360 -> 1343
1280 -> 1263
1152 -> 1135
1088 -> 1071
1024 -> 1007
960 -> 946
800 -> 783
----------------------------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment