当前位置:网站首页>Modify checkbox style
Modify checkbox style
2022-07-19 07:49:00 【guizi0809】
checkbox Default style
Take Google browser for example
<div class="box">
<input type="checkbox" /> Basketball
<input type="checkbox" /> football
<input type="checkbox" /> Table Tennis
</div>
Comes with default margin: 3px 3px 3px 4px

Default frame style
width: 10px;
height: 10px;
border-radius: 2px;
border: 1px solid rgb(118, 118, 118);
box-sizing: border-box;

Style when selected 
modify checkbox Default style
You can set the size and margin
input[type="checkbox"] {
width: 20px;
height: 20px;
margin: 0;
}

Use appearance: none Hide default checkbox The frame of , Rewrite the frame style
principle : Overwrite the original multi selection box by absolute positioning
input[type="checkbox"] {
width: 20px;
height: 20px;
margin: 0 4px 0 0;
appearance: none;
position: relative;
}
Example 1 :
/** Unselected style */
input[type="checkbox"]::before {
content: "";
position: absolute;
top: 0;
left: 0;
background: #fff;
width: 100%;
height: 100%;
border: 1px solid #d9d9d9;
border-radius: 4px;
}
/** Selected styles */
input[type="checkbox"]:checked::before {
content: "\2713"; /* 2713 Indicate tick * */
background-color: #fff;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 1px solid #7d7d7d;
border-radius: 4px;
color: #7d7d7d;
font-size: 20px;
font-weight: bold;
text-align: center;
line-height: 20px;
}
design sketch :
Example 2 :
/** Unselected style */
input[type="checkbox"] {
width: 20px;
height: 20px;
margin: 0 4px 0 0;
appearance: none;
position: relative;
background: wheat;
border-radius: 50%;
}
/** Selected styles */
input[type="checkbox"]:checked::before {
content: "";
background: orange;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
border: none;
border-radius: 50%;
}
design sketch :
边栏推荐
- 卷积神经网络CNN
- Introduction to 3D Visualization: see how rendering pipelines work in GPU
- SCI论文的Highlights怎么写(正经的教你怎么写)
- 【MySQL】 锁机制:InnoDB引擎中锁分类以及表锁、行锁、页锁详解
- Development board training: multi task program under stm32
- Summary of Statistics for Interview
- 正则表达示提取匹配内容
- 修改radio样式
- Object detection and bounding box
- Question 114 of Li Kou: binary tree expansion linked list
猜你喜欢

Web Security (XSS and CSRF)

Xiaodi network security note information collection CDN bypass technology (7)

High concurrency day01 (NiO, concurrent package)

Configuration and use of cookies and sessions

【MySQL】 MVCC:正确理解MVCC及其实现原理

Spark3.x-实战之双流join(窗口和redis实现方式和模板代码)

持续集成如何进行Jenkins管理?

如何选择合适的模型

【JVM】之堆内存、逃逸分析、栈上分配、同步省略、标量替换详解

Canel Introduction & use
随机推荐
Redis 详解
力扣114题:二叉树展开链表
Object detection and bounding box
175. 组合两个表(MySQL数据库连接)
Spark3.x-实战之mysql方式实现kafka精准一次性消费
Spark3.x entry to proficiency - stage 3 (in-depth analysis of the whole process of spark data processing)
The best storage scheme of MCU CS Chuangshi SD NAND
Environment variables and folder placement location
MySQL 02 function substr mod view view
导出文件or下载文件
SSM integration
Redis (II) - jedis
912. 排序数组(数组排序)
【MySQL】 事务:事务基础知识、MySQL事务实现原理、事务日志 redolog & undolog 详解
VMware cloud director 10.4 release (including download) - cloud computing provisioning and management platform
FMC sub card: 4-channel 250msps sampling rate 16 bit AD acquisition sub card
Gentoo installation tutorial (systemd+gnome)
卷积神经网络CNN
Configuration and use of cookies and sessions
Basic lighting knowledge of shader introduction