猿问
点击切换背景图片
左上角两到三个小图,点击不同图片能够出现不同主题背景。希望大神能够写的详细一点,谢谢
204222
浏览 1439
回答 1
1回答
superheroes丶
<!DOCTYPE HTML> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>点击切换背景</title> <style> body{ background: red; } *{ margin: 0; padding: 0; } .tit{ width: 100px; height: 100px; float: left; cursor: pointer;} #red{ background: red; } #blue{ background: blue; } #yellow{ background: yellow; } </style> <script type="text/javascript"> window.onload=function(){ var bg=document.getElementById("bg"), red=document.getElementById("red"), blue=document.getElementById("blue"), yeelow=document.getElementById("yeelow"); red.onclick=function(){ bg.style.background="red"; } blue.onclick=function(){ bg.style.background="blue"; } yellow.onclick=function(){ bg.style.background="yellow"; } } </script> </head> <body id="bg"> <div class="tit" id="red"></div> <div class="tit" id="blue"></div> <div class="tit" id="yellow"></div> </body> </html>写的比较复杂。。。不过我想这样你可以能看得更懂~还有就是颜色会比较刺眼。。。这样对应起来看得更清楚。zzZ
0
0
1
随时随地看视频
慕课网APP
相关问题
为什么字体颜色在Eclipse上没有变化
2 回答
相关分类
Html/CSS
为什么字体颜色在Eclipse上没有变化
2 回答
JavaScript
我要回答