HTML实现每天单词积累

注册页面


<html>
<head>
  <meta charset="UTF-8">
  <title>注册title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f5f5f5;
    }
    form {
      max-width: 500px;
      margin: 50px auto;
      padding: 40px;
      background-color: #fff;
      box-shadow: 0 2px 4px rgba(0,0,0,0.2);
      border-radius: 6px;
    }
    h1 {
      font-size: 36px;
      text-align: center;
      margin-top: 0;
      color: #2c3e50;
      text-shadow: 1px 1px 0 #fff;
    }
    label {
      display: block;
      margin-bottom: 10px;
      color: #2c3e50;
      text-shadow: 1px 1px 0 #fff;
      font-size: 18px;
    }
    input {
      padding: 10px;
      width: 100%;
      border: 1px solid #ccc;
      border-radius: 4px;
      margin-bottom: 20px;
      box-sizing: border-box;
      font-size: 16px;
      color: #2c3e50;
    }
    input:focus {
      outline: none;
      border-color: #51a6ff;
    }
    input[type="checkbox"] {
      width: auto;
      margin-top: 10px;
      margin-right: 5px;
    }
    button[type="submit"] {
      padding: 12px 24px;
      background-color: #51a6ff;
      color: #fff;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s ease;
      font-size: 20px;
    }
    button[type="submit"]:hover {
      background-color: #0072c6;
    }
    .error {
      color: #ff4d4d;
      font-size: 14px;
      margin-top: 5px;
    }
  style>
head>
<body>
  <form>
    <h1>注册h1>
    <label>用户名:label>
    <input type="text" name="username" required>
    <label>密码:label>
    <input type="password" name="password" required>
    <label>确认密码:label>
    <input type="password" name="confirm_password" required>
    <center>
      <label>
        <input type="checkbox" name="agree" required>
        我已同意<a href="#">注册协议a>
      label>
    center>
    <p style="text-align: right;"><button type="submit">注册button>p>
  form>
body>
html>

背单词页面


<html>
  <head>
    <meta charset="UTF-8">
    <title>背单词软件title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f0f0f0;
      }
      .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      }
      h1 {
        text-align: center;
        color: #333;
      }
      .word {
        font-size: 36px;
        color: #333;
        text-align: center;
        margin: 40px 0;
      }
      .definition {
        font-size: 24px;
        color: #666;
        text-align: center;
        margin-bottom: 40px;
      }
      .button {
        display: block;
        margin: 0 auto;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #333;
        color: #fff;
        font-size: 18px;
        text-align: center;
        cursor: pointer;
      }
      .button:hover {
        background-color: #555;
      }
    style>
  head>
  <body>
    <div class="container">
      <h1>背单词软件h1>
      <div class="word">applediv>
      <div class="definition">n. 苹果div>
      <button class="button" onclick="showNext()">下一个button>
    div>
    <script>
      // 单词和定义列表
      var words = [
        { word: 'apple', definition: 'n. 苹果' },
        { word: 'banana', definition: 'n. 香蕉' },
        { word: 'orange', definition: 'n. 橘子' },
        { word: 'grape', definition: 'n. 葡萄' },
        { word: 'watermelon', definition: 'n. 西瓜' }
      ];
      
      // 当前显示的单词索引
      var currentWordIndex = 0;
      
      // 显示下一个单词和定义
      function showNext() {
        currentWordIndex++;
        if (currentWordIndex >= words.length) {
          currentWordIndex = 0;
        }
        document.querySelector('.word').textContent = words[currentWordIndex].word;
        document.querySelector('.definition').textContent = words[currentWordIndex].definition;
      }
    script>
  body>
html>

作答题目

单词填空

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>填词游戏</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f0f0f0;
      }
      .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      }
      h1 {
        text-align: center;
        color: #333;
      }
      .word {
        font-size: 36px;
        color: #333;
        text-align: center;
        margin: 40px 0;
      }
      .letter {
        display: inline-block;
        width: 30px;
        height: 30px;
        margin: 0 20px;
        font-size: 36px;
        line-height: 50px;
        text-align: center;
        border-radius: 5px;
        background-color: #fff;
        border: 2px solid #666;
        outline: none;
        cursor: text;
      }
      .letter:focus {
        border-color: #333;
      }
      .button {
        display: block;
        margin: 0 auto;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #333;
        color: #fff;
        font-size: 18px;
        text-align: center;
        cursor: pointer;
      }
      .button:hover {
        background-color: #555;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <h1>填写出正确的字母。</h1>
      <div class="word">app<input type="text" class="letter" maxlength="1" autofocus><input type="text" class="letter" maxlength="1"></div>
      <button class="button" onclick="checkAnswer()">提交</button>
    </div>
    <script>
      // 正确答案
      var correctAnswer = 'le';
      
      // 检查玩家输入的答案
      function checkAnswer() {
        var inputLetters = document.querySelectorAll('.letter');
        var playerAnswer = '';
        for (var i = 0; i < inputLetters.length; i++) {
          playerAnswer += inputLetters[i].value;
        }
        if (playerAnswer === correctAnswer) {
          alert('答对了!');
        } else {
          alert('答错了,请再试一次。');
        }
      }
    </script>
  </body>
</html>

单词含义


<html>
  <head>
    <meta charset="UTF-8">
    <title>选单词释义游戏title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f0f0f0;
      }
      .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      }
      h1 {
        text-align: center;
        color: #333;
      }
      .word {
        font-size: 36px;
        color: #333;
        text-align: center;
        margin: 40px 0;
      }
      .options {
        margin: 40px 0;
      }
      .option {
        display: block;
        margin: 10px 0;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        color: #333;
        font-size: 24px;
        text-align: center;
        cursor: pointer;
      }
      .option:hover {
        background-color: #f0f0f0;
      }
      .button {
        display: block;
        margin: 0 auto;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #333;
        color: #fff;
        font-size: 18px;
        text-align: center;
        cursor: pointer;
      }
      .button:hover {
        background-color: #555;
      }
    style>
  head>
  <body>
    <div class="container">
      <h1>选择单词的正确释义。h1>
      <div class="word">sophisticateddiv>
      <div class="options">
        <div class="option" data-answer="1">有学问的div>
        <div class="option" data-answer="0">简单的div>
        <div class="option" data-answer="0">笨拙的div>
        <div class="option" data-answer="0">愚蠢的div>
      div>
      <button class="button" onclick="checkAnswer()">提交button>
    div>
    <script>
      // 正确答案
      var correctAnswer = 1;
      
      // 检查玩家选择的答案
      function checkAnswer() {
        var options = document.querySelectorAll('.option');
        var playerAnswer = -1;
        for (var i = 0; i < options.length; i++) {
          if (options[i].classList.contains('selected')) {
            playerAnswer = parseInt(options[i].getAttribute('data-answer'));
          }
          options[i].classList.remove('selected');
        }
        if (playerAnswer === correctAnswer) {
          alert('答对了!');
        } else {
          alert('答错了,请再试一次。');
        }
      }
      
      // 为选项添加事件监听器
      var options = document.querySelectorAll('.option');
      for (var i = 0; i < options.length; i++) {
        options[i].addEventListener('click', function() {
          for (var j = 0; j < options.length; j++) {
            options[j].classList.remove('selected');
          }
          this.classList.add('selected');
        });
      }
    script>
  body>
html>

释义选择


<html>
  <head>
    <meta charset="UTF-8">
    <title>选单词游戏title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f0f0f0;
      }
      .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      }
      h1 {
        text-align: center;
        color: #333;
      }
      .word {
        font-size: 36px;
        color: #333;
        text-align: center;
        margin: 40px 0;
      }
      .options {
        margin: 40px 0;
      }
      .option {
        display: block;
        margin: 10px 0;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        color: #333;
        font-size: 24px;
        text-align: center;
        cursor: pointer;
      }
      .option:hover {
        background-color: #f0f0f0;
      }
      .button {
        display: block;
        margin: 0 auto;
        padding: 10px 30px;
        border-radius: 5px;
        background-color: #333;
        color: #fff;
        font-size: 18px;
        text-align: center;
        cursor: pointer;
      }
      .button:hover {
        background-color: #555;
      }
    style>
  head>
  <body>
    <div class="container">
      <h1>选出正确的单词。h1>
      <div class="word">苹果div>
      <div class="options">
        <div class="option" data-answer="0">bananadiv>
        <div class="option" data-answer="0">peardiv>
        <div class="option" data-answer="1">applediv>
        <div class="option" data-answer="0">orangediv>
      div>
      <button class="button" onclick="checkAnswer()">提交button>
    div>
    <script>
      // 正确答案
      var correctAnswer = 1;
      
      // 检查玩家选择的答案
      function checkAnswer() {
        var options = document.querySelectorAll('.option');
        var playerAnswer = -1;
        for (var i = 0; i < options.length; i++) {
          if (options[i].classList.contains('selected')) {
            playerAnswer = parseInt(options[i].getAttribute('data-answer'));
          }
          options[i].classList.remove('selected');
        }
        if (playerAnswer === correctAnswer) {
          alert('答对了!');
        } else {
          alert('答错了,请再试一次。');
        }
      }
      
      // 为选项添加事件监听器
      var options = document.querySelectorAll('.option');
      for (var i = 0; i < options.length; i++) {
        options[i].addEventListener('click', function() {
          for (var j = 0; j < options.length; j++) {
            options[j].classList.remove('selected');
          }
          this.classList.add('selected');
        });
      }
    script>
  body>
html>

你可能感兴趣的:(HTML实现每天单词积累)