第十章:作业

html 复制代码
<!DOCTYPE html>  
<html>  
<head>  
    <meta charset="UTF-8">  
    <meta charset="UTF-8">  
    <title>数字时钟</title>  
    <style>  
        body {  
            display: flex;  
            flex-direction: column;  
            justify-content: center;  
            align-items: center;  
            height: 100vh;  
            margin: 0;  
            font-family: Arial, sans-serif;  
            background-color: #f0f0f0;  
        }  
 
        h1 {  
            font-size: 48px;  
            margin: 0;  
        }  
 
        .clock {  
            font-size: 64px;  
            font-weight: bold;  
            color: #333;  
        }  
 
        .label {  
            font-size: 24px;  
            margin-top: -10px;  
            color: #666;  
        }  
    </style>  
</head>  
<body>  
    <h1 class="label">数字时钟</h1>  
    <div class="clock" id="clock">00:00:00</div>  
 
    <script>  
        function updateClock() {  
            const now = new Date();  
            const hours = String(now.getHours()).padStart(2, '0');  
            const minutes = String(now.getMinutes()).padStart(2, '0');  
            const seconds = String(now.getSeconds()).padStart(2, '0');  
            document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;  
        }  
 
        setInterval(updateClock, 1000);  
        updateClock(); // 初始化时钟  
    </script>  
</body>  
</html>
html 复制代码
<!DOCTYPE html>  
<html>  
<head>  
    <meta charset="UTF-8">  
    <title>禁止右键操作</title>  
    <style>  
        body {  
            display: flex;  
            flex-direction: column;  
            justify-content: center;  
            align-items: center;  
            height: 100vh;  
            margin: 0;  
            background-color: #f0f0f0;  
            font-family: Arial, sans-serif;  
        }  
 
        .message {  
            padding: 20px;  
            background-color: #fff;  
            border: 2px solid #333;  
            border-radius: 8px;  
            text-align: center;  
            font-size: 24px;  
            margin-bottom: 20px;  
        }  
 
        img {  
            max-width: 80%;  
            height: auto;  /* 自适应高度 */  
            border-radius: 8px;  
        }  
    </style>  
</head>  
<body>  
    <div class="message">请勿使用鼠标右键!</div>  
    < img src="img/cat.jpg" alt="猫咪图片" />  
 
    <script>
        document.body.oncontextmenu = function(event) {  
            event.preventDefault();   
            alert("禁止下载图片!");  
        };  
    </script>  
</body>  
</html>
相关推荐
天外飞雨道沧桑4 分钟前
TypeScript 中 omit 和 record 用法
前端·javascript·typescript
Lee川24 分钟前
mini-cursor 揭秘:从 Tool 定义到 Agent 循环的完整实现
前端·人工智能·后端
kkeeper~1 小时前
0基础C语言积跬步之深入理解指针(5下)
c语言·开发语言
一直不明飞行1 小时前
Java的equals(),hashCode()应该在什么时候重写
java·开发语言·jvm
canonical_entropy1 小时前
从 Spec-Driven Development 到 Attractor-Guided Engineering
前端·aigc·ai编程
研☆香1 小时前
聊聊前端页面的三种长度单位
前端
盲敲代码的阿豪1 小时前
Python 入门基础教程(爬虫前置版)
开发语言·爬虫·python
给钱,谢谢!2 小时前
React + PixiJS 实现果园成长页:从状态机到浇水动画
前端·react.js·前端框架
basketball6162 小时前
C++ 构造函数完全指南:从入门到进阶
java·开发语言·c++
互联科技报2 小时前
2026超融合选型:Top5品牌与市场格局解读
开发语言·perl