Changer une propiété css via javascript
Résolu/Fermé
gibnem
-
24 févr. 2009 à 13:06
gibnem Messages postés 20 Date d'inscription mardi 24 février 2009 Statut Membre Dernière intervention 13 mai 2010 - 25 févr. 2009 à 00:50
gibnem Messages postés 20 Date d'inscription mardi 24 février 2009 Statut Membre Dernière intervention 13 mai 2010 - 25 févr. 2009 à 00:50
A voir également:
- Changer une propiété css via javascript
- Changer dns - Guide
- Changer clavier qwerty en azerty - Guide
- Changer carte graphique - Guide
- Telecharger javascript - Télécharger - Langages
- Changer wifi chromecast - Guide
7 réponses
Alain_42
Messages postés
5361
Date d'inscription
dimanche 3 février 2008
Statut
Membre
Dernière intervention
13 février 2017
894
24 févr. 2009 à 13:23
24 févr. 2009 à 13:23
as tu mis dans ta page <body id="body"> ?
sinon tu peux esayer:
sinon tu peux esayer:
document.body.style.background = ....
en faite dans ma page de style css ila ya
body {
background: #0012ff url(images/30.png) no-repeat right bottom fixed;
margin-bottom: 20px;
}
body {
background: #0012ff url(images/30.png) no-repeat right bottom fixed;
margin-bottom: 20px;
}
j'ai essayé comme ce que ta dit
if(largeur < 1200){
document.body.style.background = #0012ff url(images/30.png) no-repeat right bottom fixed;
}
else{
document.body.style.background = #2746E0 url(images/3.png) no-repeat right bottom fixed;
}
mais ça n'a pas marché!!
if(largeur < 1200){
document.body.style.background = #0012ff url(images/30.png) no-repeat right bottom fixed;
}
else{
document.body.style.background = #2746E0 url(images/3.png) no-repeat right bottom fixed;
}
mais ça n'a pas marché!!
Alain_42
Messages postés
5361
Date d'inscription
dimanche 3 février 2008
Statut
Membre
Dernière intervention
13 février 2017
894
24 févr. 2009 à 17:50
24 févr. 2009 à 17:50
et:
if(largeur < 1200){ body.style.background = #0012ff url(images/30.png) no-repeat right bottom fixed; } else{ body.style.background = #2746E0 url(images/3.png) no-repeat right bottom fixed; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Alain_42
Messages postés
5361
Date d'inscription
dimanche 3 février 2008
Statut
Membre
Dernière intervention
13 février 2017
894
24 févr. 2009 à 17:51
24 févr. 2009 à 17:51
pardon:
if(largeur < 1200){ body.style.background =" #0012ff url(images/30.png) no-repeat right bottom fixed"; } else{ body.style.background =" #2746E0 url(images/3.png) no-repeat right bottom fixed"; }
Marco la baraque
Messages postés
996
Date d'inscription
vendredi 9 mai 2008
Statut
Contributeur
Dernière intervention
5 novembre 2009
329
24 févr. 2009 à 22:13
24 févr. 2009 à 22:13
Bonsoir,
Essaie en ajoutant des double-quote :
Cordialement,
Essaie en ajoutant des double-quote :
document.body.style.background = "#0012ff url(images/30.png) no-repeat right bottom fixed";
Cordialement,
gibnem
Messages postés
20
Date d'inscription
mardi 24 février 2009
Statut
Membre
Dernière intervention
13 mai 2010
8
25 févr. 2009 à 00:50
25 févr. 2009 à 00:50
bon merci a vous tous
voici le code final et ça marche cristal XD
if(largeur < 1200){
document.body.style.background = "#0012ff";
document.body.style.backgroundImage='url(images/30.png)';
document.body.style.backgroundPosition = 'right bottom';
document.body.style.backgroundRepeat = 'no-repeat';
document.body.style.backgroundAttachment = 'fixed';
}
else{
document.body.style.background = "#2746E0";
document.body.style.backgroundImage='url(images/3.png)';
document.body.style.backgroundPosition = 'right bottom';
document.body.style.backgroundRepeat = 'no-repeat';
document.body.style.backgroundAttachment = 'fixed';
}
voici le code final et ça marche cristal XD
if(largeur < 1200){
document.body.style.background = "#0012ff";
document.body.style.backgroundImage='url(images/30.png)';
document.body.style.backgroundPosition = 'right bottom';
document.body.style.backgroundRepeat = 'no-repeat';
document.body.style.backgroundAttachment = 'fixed';
}
else{
document.body.style.background = "#2746E0";
document.body.style.backgroundImage='url(images/3.png)';
document.body.style.backgroundPosition = 'right bottom';
document.body.style.backgroundRepeat = 'no-repeat';
document.body.style.backgroundAttachment = 'fixed';
}