用html写一个时钟特效
时间: 2023-03-31 12:04:24 浏览: 104
好的,以下是用 HTML 写一个时钟特效的代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>时钟特效</title>
<style>
body {
background-color: #333;
color: #fff;
font-size: 3em;
text-align: center;
margin-top: 100px;
}
</style>
</head>
<body>
<script>
function updateTime() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
hours = hours < 10 ? "" + hours : hours;
minutes = minutes < 10 ? "" + minutes : minutes;
seconds = seconds < 10 ? "" + seconds : seconds;
document.body.innerHTML = hours + ":" + minutes + ":" + seconds;
}
setInterval(updateTime, 100);
</script>
</body>
</html>
```
希望对你有帮助!
阅读全文