打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
js实现网页换肤
这篇文章主要为大家详细介绍了js实现网页换肤功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了js实现网页换肤的具体代码,供大家参考,具体内容如下
效果:
代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
}
body{
height: 100%;
width: 100%;
}
#main{
height: 720px;
width: 100%;
background-color: pink;
}
button{
height: 15px;
width: 15px;
border: 1px solid #fff;
margin: 10px 10px;
}
#red{
background-color: red;
}
#green{
background-color: green;
}
#blue{
background-color: blue;
}
</style>
</head>
<body>
<div id="main">
<button type="button" id="red" onclick="red()"></button>
<button type="button" id="green" onclick="green()"></button>
<button type="button" id="blue" onclick="blue()"></button>
</div>
<script type="text/javascript">
var x=document.getElementById('main');
function red(){
x.style.backgroundColor='red';
document.getElementById('red').style.border="3px solid white";
document.getElementById('green').style.border="1px solid white";
document.getElementById('blue').style.border="1px solid white";
}
function green(){
x.style.backgroundColor='green';
document.getElementById('green').style.border="3px solid white";
document.getElementById('red').style.border="1px solid white";
document.getElementById('blue').style.border="1px solid white";
}
function blue(){
x.style.backgroundColor='blue';
document.getElementById('blue').style.border="3px solid white";
document.getElementById('red').style.border="1px solid white";
document.getElementById('green').style.border="1px solid white";
}
</script>
</body>
</html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
带关闭按钮的悬浮层
div高度自适应方法总结
网页浮动特效代码
右下角出现提示DIV
摘录固定表头
JS实现DIV层随滚动条滚动
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服