左上角两到三个小图,点击不同图片能够出现不同主题背景。希望大神能够写的详细一点,谢谢
1 回答
已采纳

superheroes丶
TA贡献9条经验 获得超5个赞
<!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/150
提交
取消