当前位置:网站首页>修改radio样式
修改radio样式
2022-07-17 05:25:00 【guizi0809】
radio默认样式
以谷歌浏览器为例
<div class="box">
<input class="radio" type="radio" name="sex" />男
<input class="radio" type="radio" name="sex" />女
<input class="radio" type="radio" name="sex" />保密
</div>
自带默认margin: 3px 3px 0px 5px
默认框框样式
width: 10px;
height: 10px;
border: 1px solid rgb(118, 118, 118);
border-radius: 50%;
box-sizing: border-box;
选中时的样式
修改radio默认样式
可以设置尺寸和边距
input[type="radio"] {
width: 20px;
height: 20px;
margin: 0;
}
使用appearance: none隐藏默认radio的框框,重写框框样式
原理:通过绝对定位覆盖原多选框
input[type="radio"] {
width: 20px;
height: 20px;
margin: 0 4px 0 0;
appearance: none;
position: relative;
}
示例一:
/** 未被选中的样式*/
input[type="radio"]::before {
content: "";
position: absolute;
top: 0;
left: 0;
background: #fff;
width: 100%;
height: 100%;
border: 1px solid #d9d9d9;
border-radius: 4px;
}
/** 选中的样式 */
input[type="radio"]:checked::before {
content: "\2713"; /* 2713表示勾勾* */
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;
}
效果图:
示例二:
/** 未被选中的样式*/
input[type="radio"] {
width: 20px;
height: 20px;
margin: 0 4px 0 0;
appearance: none;
position: relative;
background: wheat;
border-radius: 50%;
}
/** 选中的样式*/
input[type="radio"]:checked::before {
content: "";
background: orange;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
border: none;
border-radius: 50%;
}
效果图:
边栏推荐
- Redis(二) - Jedis
- 网络知识-03 数据链路层-以太网
- FreeBSD 12 installing RPM packages
- [quantitative notes] the meaning of relevant technical indicators of volatility
- Fundamentals of crawlers - basic principles of multithreading and multiprocessing
- Administrator blocked this app from running
- 如何选择合适的模型
- 2021-10-25 浏览器兼容遇到的问题
- Network knowledge-05 transport layer UDP
- Flink入门到实战-阶段三(DataStreamAPI)
猜你喜欢
Network knowledge-04 network layer ICMP Protocol
实操教程:CANoe在CAN总线测试中的应用
Understanding of v2x test series v2x phase II application scenario
面部关键点检测-CNN
Spark3.x entry to proficiency - stage 3 (in-depth analysis of the whole process of spark data processing)
网络知识-05 传输层-TCP
[operation rules] how to realize TSN system level test?
How does Jenkins set the mailbox to automatically send mail?
Notepad++ underline and case letter replacement
Pytorch随记(3)
随机推荐
SSM integration
Summary of Statistics for Interview
HMI概念设计的未来在哪里?
面部关键点检测-CNN
Promote trust in the digital world
60. Clear cache
JS does not use async/await to solve the problem of data asynchrony / synchronization
Filter filter
9. Account and authority
网络知识-02 物理层
Install SQL developer for Galaxy Kirin desktop operating system v10sp1 (x86)
Pytorch随记(3)
Tail -f pause method
MySql
3D可视化入门基础:看渲染管线如何在GPU运作
预测销售XGBoost
SQL skimming summary SQL leetcode review
Network knowledge-04 network layer IPv6
Network knowledge-03 data link layer PPP
ivew 穿梭框Transfer组件高亮显示操作值