Anglais [?b?kɡraund ?imid?] US [?b?k?ɡra?nd ??m?d?]
Image d'arrière-plan
Propriété backgroundImage javascript syntaxe
Fonction?: Définissez l'image d'arrière-plan de l'élément.
Syntaxe?: Object.style.backgroundImage=url(URL)|none
Paramètres?: url(URL) Chemin d'accès à l'image. none Aucune image d'arrière-plan.?
Remarque?: Veuillez définir une couleur d'arrière-plan disponible, de sorte que si l'image d'arrière-plan n'est pas disponible, la page puisse également obtenir de bons effets visuels.
Propriété backgroundImage javascript exemple
<html> <head> <script type="text/javascript"> function changeStyle() { document.body.style.backgroundColor="#FFCC80"; document.body.style.backgroundImage="url(http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg)"; } </script> </head> <body> <input type="button" onclick="changeStyle()" value="Set background image" /> </body> </html>
Exécuter l'instance ?
Cliquez sur le bouton ??Exécuter l'instance?? pour afficher l'instance en ligne