一个简单的 HTML + CSS + JavaScript 实现的搜索页面

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Search Page</title>
  <style>
    /* Add styles for the page */
    .container {
      width: 80%;
      margin: 0 auto;
      text-align: center;
    }

    .search-container {
      margin-top: 50px;
    }

    input[type="text"] {
      width: 60%;
      height: 30px;
      padding: 5px;
      border: 1px solid #ccc;
      font-size: 16px;
      border-radius: 5px;
    }

    button[type="submit"] {
      width: 20%;
      height: 35px;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 5px;
      cursor: pointer;
    }

    button[type="submit"]:hover {
      background-color: #3e8e41;
    }
  </style>
</head>
<body>
  <!-- Add a container for the page -->
  <div class="container">
    <!-- Add a form for the search box -->
    <div class="search-container">
      <form action="#">
        <input type="text" placeholder="Search..." id="searchBox">
        <button type="submit">Search</button>
      </form>
    </div>

    <!-- Add a container for the search results -->
    <div id="searchResults"></div>
  </div>

  <!-- Add JavaScript to handle the search functionality -->
  <script>
    const searchBox = document.getElementById("searchBox");
    const searchResults = document.getElementById("searchResults");

    searchBox.addEventListener("input", function() {
      const searchTerm = this.value;
      searchResults.innerHTML = "Search results for: " + searchTerm;
    });
  </script>
</body>
</html>

这个代码将创建一个简单的搜索页面,包括一个搜索框和一个用于显示搜索结果的容器。当用户在搜索框中输入内容时,搜索结果容器中的内容将根据搜索框中的内容进行更新。

这是一个简单的模板,您可以根据自己的需要进行修改和扩充

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是一个简单HTML + CSS + JavaScript 登录页面的示例代码: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Login</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; padding: 20px; } form { background-color: #fff; border: 1px solid #ccc; padding: 20px; max-width: 500px; margin: 0 auto; text-align: center; } h1 { margin-top: 0; } label { display: block; margin-bottom: 10px; } input[type="text"], input[type="password"] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 20px; } button { background-color: #4CAF50; color: #fff; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } </style> </head> <body> <form> <h1>Login</h1> <label for="username">Username</label> <input type="text" id="username" name="username" placeholder="Enter your username"> <label for="password">Password</label> <input type="password" id="password" name="password" placeholder="Enter your password"> <button type="submit" onclick="login()">Login</button> </form> <script> function login() { // 获取输入框的值 var username = document.getElementById("username").value; var password = document.getElementById("password").value; // 模拟登录验证 if (username === "admin" && password === "admin") { alert("登录成功!"); } else { alert("用户名或密码错误!"); } } </script> </body> </html> ``` 这个示例页面包含一个表单,包括用户名和密码输入框,以及一个“登录”按钮,当用户点击“登录”按钮时,会触发 JavaScript 函数 `login()` 进行登录验证,如果用户名和密码正确,则弹出提示框显示“登录成功”,否则显示“用户名或密码错误”。该页面还包含一些简单CSS 样式,用于使页面看起来更美观。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

终将老去的穷苦程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值