-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path进制转换器.html
131 lines (114 loc) · 3.8 KB
/
进制转换器.html
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="applestyles.css">
<title>进制转换器</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
text-align: center;
padding-top: 50px;
}
#converter {
margin: 0 auto;
width: 300px;
background-color: #ffffff;
border-radius: 5px;
padding: 20px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
input[type="number"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #cccccc;
border-radius: 5px;
font-size: 16px;
}
select {
width: 100%;
padding: 10px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #cccccc;
border-radius: 5px;
font-size: 16px;
}
button {
width: 100%;
padding: 10px;
background-color: #4caf50;
border: none;
border-radius: 5px;
color: #ffffff;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<header>
<!-- 导航栏 -->
<nav>
<ul>
<li><a href="index.html"><img src="applewebuiimg/apple-icon.png" alt="Apple-icon"></a></li>
<li><a href="Mac.html">Mac</a></li>
<li><a href="ipad.html">iPad</a></li>
<li><a href="iphone.html">iPhone</a></li>
<li><a href="watch.html">Watch</a></li>
<li><a href="tv.html">TV</a></li>
<li><a href="music.html">Music</a></li>
<li><a href="support.html">Support</a></li>
<li><a href="plugins/chatweb/chatgpt2.html">ChatGPT</a></li>
<li><a href="进制转换器.html">进制转换器</a></li>
</ul>
</nav>
</header>
<div class="ymh1">
<h1>进制转换器</h1>
</div>
<div id="converter">
<input type="number" id="inputNumber" placeholder="输入一个整数">
<select id="fromBase">
<option value="2">二进制</option>
<option value="8">八进制</option>
<option value="10" selected>十进制</option>
<option value="16">十六进制</option>
</select>
<select id="toBase">
<option value="2">二进制</option>
<option value="8">八进制</option>
<option value="10" selected>十进制</option>
<option value="16">十六进制</option>
</select>
<button onclick="convert()">转换</button>
<div id="result"></div>
</div>
<script>
function convert() {
var inputNumber = document.getElementById("inputNumber").value;
var fromBase = document.getElementById("fromBase").value;
var toBase = document.getElementById("toBase").value;
// 转换为十进制
var decimalNumber = parseInt(inputNumber, fromBase);
// 根据目标进制进行转换
var result = decimalNumber.toString(toBase);
document.getElementById("result").innerHTML = result;
}
</script>
<footer>
<!-- 页脚 -->
<p>© 2023 Apple Inc. 保留所有权利。</p>
</footer>
</body>
</html>