惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
H
Heimdal Security Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
AWS News Blog
AWS News Blog
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Hacker News
The Hacker News
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
S
Securelist
P
Privacy International News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
博客园 - 叶小钗
J
Java Code Geeks
V
V2EX
博客园 - Franky
Spread Privacy
Spread Privacy
K
Kaspersky official blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
C
CERT Recently Published Vulnerability Notes
Latest news
Latest news
NISL@THU
NISL@THU
罗磊的独立博客
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
V
Visual Studio Blog

博客园 - smil、梵音

C语言标准(C89/C90)中的32个关键字全列表 Windows 系统的 vscode 通过 Remote-SSH 连接虚拟机的 Ubuntu 系统运行 C 语言的代码 Windows 系统 vscode Remote-SSH 远程连接虚拟机里面的Ubuntu系统的失败处理 Ubuntu虚拟机里安装了SSH,开启SSH服务的时候报错 VS Code的Remote - SSH功能 Ubuntu系统里面安装 g++ ,sudo apt update 的含义 C语言是不是必须得通过gcc编译成可执行的程序? c语言用gcc编译过后,执行 ./hello.c 报错 ./hello.c: 权限不够 windows系统的虚拟机里面的Ubuntu系统安装VMware Tools Ubuntu的应用中心搜索 vscode 的时候,筛选条件为Snap包、debian包是什么意思,如何安装vscode Ubuntu系统是否就是Linux系统,安装软件和Windows系统有何区别 Ubuntu系统里面vscode运行C语言的第一个 Hello World 程序 vscode 中安装C/C++相关的插件 Ubuntu 安装一个轻量级的中文输入法Fcitx5 Ubuntu安装百度网盘 Ubuntu系统里面安装vscode 乌版图系统截屏快捷键 Ubuntu 系统里面运行C++ TortoiseGit 的安装与汉化 安装虚拟机+ ubuntu24.04 系统 联想小新安装 ubuntu24.04 双系统 | 安装乌版图系统 | windows安装 ubuntu24.04 双系统 利用faststone capture制作gif动图 Sublime Text 常用编辑快捷键速查表 vscode 中的 css 样式代码不显示折叠图标的解决方法 IDEA中git的Cherry-Pick的可视化使用(个人总结) IDEA中git的Cherry-Pick的使用 IDEA中如何实现git的cherry-pick可视化操作? Windows11添加系统环境变量 VS Code——Live Server的简介、安装与使用 vue3中 pinia 的运用 vscode使用region折叠任意想折叠的代码块 我本地分支代码推送到远程的另一个分支,怎么操作? idea中打开多文件编辑器换行展示 本地代码强制覆盖远程代码,本地代码强制和远程某一个分支保持一致,再覆盖远程代码 css头部固定,内容区域高度自适应剩余的屏幕高度,内容区域过多显示竖向滚动条 flex为1的元素宽度自适应的同时,文本太长的时候显示省略号 idea中项目文件目录消失如何解决 vue3插入图片 vue3使用构建工具时,关于本地图片的引用 vue3 中父组件调用子组件的方法,子组件是不是必须暴露方法 vue3中非父子组件、非祖先-后代组件之间传递方法 解决 IntelliJ IDEA 中项目右键没有 Git 菜单的问题 关于 ref 为 DOM 元素或子组件实例动态创建引用的总结 Git 合并时出现 Please enter a commit message to explain why this merge is necessary 问题解决 拉取远程其他分支的最新代码
如何改变type="checkbox"的input复选框的样式
smil、梵音 · 2025-03-26 · via 博客园 - smil、梵音

<input type="checkbox">默认的样式是由浏览器控制的,直接修改它的样式比较困难。可以通过一些CSS技巧来实现自定义样式,包括改变颜色。

直接上例子吧:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Custom Checkbox</title>
  <style>
    /* 隐藏原生的checkbox */
    .custom-checkbox input[type="checkbox"] {
      opacity: 0;
      position: absolute;
    }

    /* 自定义样式 */
    .custom-checkbox label {
      display: inline-block;
      width: 20px;
      height: 20px;
      border: 2px solid red;
      border-radius: 4px;
      position: relative;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    /* 当checkbox被选中时的样式 */
    .custom-checkbox input[type="checkbox"]:checked + label {
      background-color: blue; /* 改变选中时的背景颜色 */
    }

    /* 添加一个小勾勾 */
    .custom-checkbox input[type="checkbox"]:checked + label::after {
      content: "";
      position: absolute;
      top: 4px;
      left: 6px;
      width: 8px;
      height: 4px;
      border: 2px solid white;
      border-top: none;
      border-right: none;
      transform: rotate(-45deg);
    }
  </style>

  <style>
    /* 自定义样式 */
    .custom-checkbox input[type="checkbox"] {
      width: 20px;
      height: 20px;
      border: 2px solid #000;
      border-radius: 4px;
      cursor: pointer;
      transition: background-color 0.3s ease, border-color 0.3s ease;
    }

    /* 当checkbox被选中时的样式 */
    .custom-checkbox input[type="checkbox"]:checked {
      background-color: blue; /* 改变选中时的背景颜色 */
      border-color: blue; /* 改变选中时的边框颜色 */
    }
  </style>
</head>
<body>
  <div class="custom-checkbox">
    <input type="checkbox" id="checkbox1">
    <label for="checkbox1"></label>
  </div>

  <br/>
  <h1>----------------------</h1>
  <div class="custom-checkbox">
    <input type="checkbox" id="checkbox3">
    <label for="checkbox3"></label>
  </div>
</body>
</html>