Adapter mon background aux résolutions
marco
-
marco -
marco -
Bonjour, j'aimerai adapter mon background a toute les résolution et en cherchant j'ai trouvé ce code. pouvez vous me dire quoi modifier et ou mettre ce code dans ma page html. merci
code"
var background = function () // création d'une fonction background()
{
var res = [ // de la plus petite à la plus grande, les différents backgrounds avec leurs dimensions
{width:800, height:600, src:"tonimage3.jpg"},
{width:1024, height:768, src:"tonimage2.jpg"},
{width:1280, height:800, src:"tonimage.jpg"}];
// Au départ, on prend le premier background
var img = res[0],
width = window.innerWidth || (document.body && document.body.clientWidth) || 1024; // On récupère la largeur de la fenêtre
for (var i=0; i < res.length;i++) { // On fait une boucle sur le tableau des backgrounds
if (img.width <= res[i].width && res[i].width <= width) { // Et on cherche lequel est le plus approprié
img = res[i];
}
else {
break; // Si on a trouvé le bon, on quitte la boucle
}
}
if (document.body) {
document.body.style.backgroundImage = "url('"+ img.src +"')"; // On applique le background au style du body
}
}
window.onresize = background; // Au redimensionnement de la fenêtre, on appelera la fonction
window.onload = background; // Au chargement, on appelera la fonction
code"
var background = function () // création d'une fonction background()
{
var res = [ // de la plus petite à la plus grande, les différents backgrounds avec leurs dimensions
{width:800, height:600, src:"tonimage3.jpg"},
{width:1024, height:768, src:"tonimage2.jpg"},
{width:1280, height:800, src:"tonimage.jpg"}];
// Au départ, on prend le premier background
var img = res[0],
width = window.innerWidth || (document.body && document.body.clientWidth) || 1024; // On récupère la largeur de la fenêtre
for (var i=0; i < res.length;i++) { // On fait une boucle sur le tableau des backgrounds
if (img.width <= res[i].width && res[i].width <= width) { // Et on cherche lequel est le plus approprié
img = res[i];
}
else {
break; // Si on a trouvé le bon, on quitte la boucle
}
}
if (document.body) {
document.body.style.backgroundImage = "url('"+ img.src +"')"; // On applique le background au style du body
}
}
window.onresize = background; // Au redimensionnement de la fenêtre, on appelera la fonction
window.onload = background; // Au chargement, on appelera la fonction
A voir également:
- Adapter mon background aux résolutions
- Windows 7 logon background changer - Télécharger - Thèmes & Fonds d'écran
- Excel adapter taille cellule au texte ✓ - Forum Excel
- John's background switcher - Télécharger - Suite bureautique
- Background task host c'est quoi - Forum Windows
- Starter background changer - Télécharger - Thèmes & Fonds d'écran