蓝桥杯Web应用开发-CSS3 新特性【练习一:属性有效性验证】

练习一:属性有效性验证

页面上有一个邮箱输入框,当你的输入满足邮箱格式时,输入框的背景颜色为绿色;当你的输入不满足要求,背景颜色为红色。

新建一个 index2.html 文件,在其中写入以下内容。

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /*格式错误*/
      input:invalid {
        background-color: red;
      }
      /*格式正确*/
      input:valid {
        background-color: green;
      }
    </style>
  </head>
  <body>
    电子邮箱:<input type="email" />
  </body>
</html>
相关推荐
快乐肚皮35 分钟前
深入理解Loop Engineering
前端·后端
风骏时光牛马1 小时前
VHDL十大经典基础功能设计实例代码合集
前端
hunterandroid1 小时前
Notification 通知:从基础到渠道适配
前端
孟陬1 小时前
Claude Code 巧思 `Ctrl+S` 暂存键
前端·后端
PedroQue991 小时前
V1.6.1性能优化:高频路径提速与代码精简
前端·uni-app
猩猩程序员2 小时前
将 LiteLLM 迁移到 Rust —— 构建最快、最轻量的 AI Gateway
前端
lichenyang4532 小时前
JSBridge 分发升级:为什么要从 if-else 变成 Registry > 这是「ASCF 架构升级」系列的第 3 篇
前端
码上天下2 小时前
流式响应断了,前端怎么自动重连续传
前端
anyup2 小时前
来简单聊聊鸿蒙开发,万元奖金的事~
前端·华为·harmonyos
北凉温华2 小时前
Univer 在线表格模块使用说明
前端