第十章:作业

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>
相关推荐
努力学习的小廉3 分钟前
Python基础——搭建 Python 环境
开发语言·python
luanma1509804 分钟前
Laravel 4.x:现代PHP框架的奠基之作
开发语言·php·laravel
yaaakaaang5 分钟前
(六)前端,如此简单!--- 三类通讯
前端
清水白石00813 分钟前
Python 编程全景解析:四大核心容器的性能较量、语义之美与高阶实战
开发语言·数据库·python
淀粉肠kk13 分钟前
【C++】C++11 Lambda表达式
开发语言·c++
南境十里·墨染春水14 分钟前
CMake核心用法(贴合C++编译场景)
开发语言·c++
Jinuss19 分钟前
源码分析之React中副作用Effect全流程
前端·javascript·react.js
Rust语言中文社区20 分钟前
【Rust日报】 Danube Messaging - 云原生消息平台
开发语言·后端·rust
kaikaile199523 分钟前
微电网两阶段鲁棒优化经济调度MATLAB实现
开发语言·matlab
踩着两条虫24 分钟前
VTJ.PRO 在线应用开发平台的低代码引擎与DSL系统
前端·低代码·ai编程