为了创建一个展示当前时间的好看网页,可以使用 HTML 和 CSS 来设计页面,JavaScript 来动态更新时间。以下是一个简单的示例,包括了基本的样式和 JavaScript 代码来实时显示当前时间。
HTML 文件 (index.html
)
CSS 文件 (styles.css
)
JavaScript 文件 (script.js
)
说明
- HTML: 定义了网页结构,包括一个容器和一个显示时间的区域。
- CSS: 提供了简洁的样式,使时间显示区域居中,背景为白色,并添加了圆角和阴影效果。
- JavaScript: 通过
setInterval
每秒更新一次显示的时间,并且在页面加载时立即显示时间。
将这三个文件放在同一目录下,然后用浏览器打开 index.html
,会看到一个简洁且现代的网页,实时显示当前时间。可以根据需要进一步自定义样式和功能。