写一个 透明背景的电子时钟html5
<!DOCTYPE html>
<html>
<head>
<title>透明背景的电子时钟</title>
<script>
function displayTime() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var meridiem = "AM";
<pre><code> if (hours > 12) {
hours = hours - 12;
meridiem = "PM";
}
if (hours === 0) {
hours = 12;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var time = hours + ":" + minutes + ":" + seconds + " " + meridiem;
document.getElementById("clock").innerHTML = time;
}
setInterval(displayTime, 1000);
</script>
<style>
body {
margin: 0;
padding: 0;
background-color: transparent;
}
#clock {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 5em;
font-family: Arial, sans-serif;
color: #fff;
text-shadow: 0px 0px 10px #000;
}
</style>
</code></pre>
</head>
<body>
<div id="clock"></div>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/0nT 著作权归作者所有。请勿转载和采集!