第十章:作业

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>
相关推荐
威风的虫2 分钟前
JavaScript中的axios
开发语言·javascript·ecmascript
比老马还六6 分钟前
Blockly元组积木开发
前端
老赵的博客7 分钟前
c++ 是静态编译语言
开发语言·c++
Terio_my7 分钟前
Python制作12306查票工具:从零构建铁路购票信息查询系统
开发语言·python·microsoft
笨笨狗吞噬者10 分钟前
【uniapp】小程序体积优化,JSON文件压缩
前端·微信小程序·uni-app
bot55566615 分钟前
“企业微信iPad协议”静默 72 小时:一台被遗忘的测试机如何成为私域的逃生梯
javascript·面试
西洼工作室19 分钟前
浏览器事件循环与内存管理可视化
前端·javascript·css·css3
消失的旧时光-194330 分钟前
Kotlin when 用法完整分享
android·开发语言·kotlin
万粉变现经纪人30 分钟前
如何解决 pip install -r requirements.txt 约束文件 constraints.txt 仅允许固定版本(未锁定报错)问题
开发语言·python·r语言·django·beautifulsoup·pandas·pip
xier12345639 分钟前
高性能和高灵活度的react表格组件
前端