需要代写一个网页,使用HTML语言

需要写一个网站代码,实现动态交互,里边需要有五个不同的事件响应

img

引用chatgpt部分指引作答:
我可以帮你设计一个满足你要求的网页。下面是一个简单的示例,展示了一个基本的网页结构,使用jQuery添加了一些动态交互效果,并包含了超过5个不同事件的效果。

<!DOCTYPE html>
<html>
<head>
  <title>动态交互网页</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f2f2f2;
      margin: 0;
      padding: 0;
    }

    h1 {
      color: #333;
      text-align: center;
      margin-top: 50px;
    }

    .box {
      width: 200px;
      height: 200px;
      background-color: #ccc;
      margin: 50px auto;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 20px;
      color: #fff;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    .box:hover {
      background-color: #666;
    }
  </style>
</head>
<body>
  <h1>动态交互网页</h1>

  <div class="box">点击我!</div>

  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
    // 点击事件
    $(".box").click(function() {
      $(this).text("被点击了!");
    });

    // 鼠标悬停事件
    $(".box").hover(
      function() {
        $(this).css("font-size", "25px");
      },
      function() {
        $(this).css("font-size", "20px");
      }
    );

    // 淡入淡出动画
    $(".box").on("dblclick", function() {
      $(this).fadeOut(500).fadeIn(500);
    });

    // 拖拽事件
    $(".box").draggable();

    // 键盘事件
    $(document).keydown(function(event) {
      if (event.key === "r") {
        $(".box").css("background-color", "red");
      } else if (event.key === "g") {
        $(".box").css("background-color", "green");
      } else if (event.key === "b") {
        $(".box").css("background-color", "blue");
      }
    });
  </script>
</body>
</html>

这个示例页面包含一个标题,一个可点击的方块元素,并使用jQuery添加了以下交互效果:

1 点击方块元素后,会改变其文本内容。
2 鼠标悬停在方块元素上时,字体大小会增大。
3 双击方块元素后,会有淡入淡出的动画效果。
4 方块元素可以被拖拽移动。
5 当按下键盘上的 "r" 键时,方块元素的背景色会变为红色;按下 "g" 键时,背景色变为绿色;按下 "b" 键时,背景色变为蓝色。
这只是一个简单的示例,你可以根据自己的需求进行更多的定制和添加更多的交互效果。

<!DOCTYPE html>
<html>
<head>
    <title>jQuery动态交互效果示例</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: red;
            position: relative;
            margin: 50px auto;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
        }
        .box:hover {
            transform: scale(1.1);
        }
        .circle {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-color: blue;
            position: absolute;
            top: 25px;
            left: 25px;
            transition: all 0.3s ease-in-out;
        }
        .box:hover .circle {
            transform: rotate(360deg);
        }
        .text {
            font-size: 24px;
            color: white;
            text-align: center;
            line-height: 100px;
        }
        .hidden {
            display: none;
        }
        .show {
            display: block;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="circle"></div>
        <div class="text">点击我</div>
    </div>
    <div class="hidden">
        <p>这是一个隐藏的段落。</p>
    </div>
    <button id="toggle-btn">显示/隐藏</button>
    <script>
        $(document).ready(function() {
            // 点击盒子时,盒子会向右移动
            $('.box').click(function() {
                $(this).animate({left: '+=50px'}, 500);
            });

            // 鼠标移入/移出按钮时,按钮会变色
            $('#toggle-btn').hover(function() {
                $(this).css('background-color', 'green');
            }, function() {
                $(this).css('background-color', 'white');
            });

            // 点击按钮时,隐藏/显示段落
            $('#toggle-btn').click(function() {
                $('.hidden').toggle('slow');
            });

            // 双击盒子时,盒子会变成蓝色
            $('.box').dblclick(function() {
                $(this).css('background-color', 'blue');
            });

            // 鼠标按下/松开时,盒子会变成黄色/红色
            $('.box').mousedown(function() {
                $(this).css('background-color', 'yellow');
            }).mouseup(function() {
                $(this).css('background-color', 'red');
            });
        });
    </script>
</body>
</html>

引入ChatGPT部分内容参考:
HTML代码:

<!DOCTYPE html>
<html>
<head>
    <title>动态交互网页</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <header>
        <h1>动态交互网页</h1>
        <nav>
            <ul>
                <li><a href="#">首页</a></li>
                <li><a href="#">关于我们</a></li>
                <li><a href="#">联系我们</a></li>
            </ul>
        </nav>
    </header>
    <main>
        <section>
            <h2>欢迎来到动态交互网页</h2>
            <p>这是一个演示动态交互效果的网页,使用jQuery编程实现。</p>
            <button id="btn1">点击我</button>
            <button id="btn2">悬停我</button>
            <button id="btn3">双击我</button>
            <button id="btn4">滚动我</button>
            <button id="btn5">淡入淡出</button>
            <img src="image.jpg" alt="图片">
        </section>
    </main>
    <footer>
        <p>版权所有 &copy; 2021 动态交互网页</p>
    </footer>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="script.js"></script>
</body>
</html>

CSS代码:

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
}

header {
    background-color: #333;
    color: #fff;
    padding: 20px;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

nav li {
    display: inline-block;
    margin-right: 20px;
}

nav a {
    color: #fff;
    text-decoration: none;
}

main {
    padding: 20px;
}

section {
    margin-bottom: 20px;
}

h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

p {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

button {
    background-color: #333;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 10px 20px;
    margin-right: 10px;
}

img {
    max-width: 100%;
    height: auto;
}

footer {
    background-color: #333;
    color: #fff;
    padding: 20px;
    text-align: center;
}

JavaScript代码:

$(document).ready(function() {
    // 点击按钮1,弹出提示框
    $("#btn1").click(function() {
        alert("你点击了按钮1");
    });

    // 鼠标悬停在按钮2上,改变背景颜色
    $("#btn2").hover(function() {
        $(this).css("background-color", "#666");
    }, function() {
        $(this).css("background-color", "#333");
    });

    // 双击按钮3,隐藏图片
    $("#btn3").dblclick(function() {
        $("img").hide();
    });

    // 滚动页面,改变标题颜色
    $(window).scroll(function() {
        if ($(this).scrollTop() > 100) {
            $("h1").css("color", "#f00");
        } else {
            $("h1").css("color", "#fff");
        }
    });

    // 点击按钮4,平滑滚动到页面底部
    $("#btn4").click(function() {
        $("html, body").animate({scrollTop: $(document).height()}, "slow");
    });

    // 点击按钮5,图片淡入淡出
    $("#btn5").click(function() {
        $("img").fadeOut("slow", function() {
            $(this).attr("src", "image2.jpg").fadeIn("slow");
        });
    });
});