html自定义radio checkbox样式
来源:互联网 发布:教务系统数据库设计 编辑:程序博客网 时间:2024/05/18 19:40
思路一:
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input[type="radio"] {
display: none;
}
.sex-label {
margin-left: 20px;
position: relative;
}
.sex-label::before{
content: '';
display: inline-block;
width: 1em;
height: 1em;
border-radius: 50%;
border: 1px solid #ccc;
position: absolute;
left: -20px;
top: 0.2em;
box-sizing: border-box;
padding: 0.2em;
}
.sex-label.radio-check::before{
background: red;
background-position: center center;
background-clip: content-box;
}
</style>
</head>
<body>
<label class="sex-label" for="boy" >男生</label>
<input type="radio" id="boy" name="sex">
<label class="sex-label" for="girl">女生</label>
<input type="radio" id="girl" name="sex">
<script>
document.getElementsByClassName('sex-label')[0].onclick = function(event) {
// this.classList.add('radio-check')
console.log(this.classList)
if(this.classList.value.indexOf('radio-check') > 0){
this.classList.remove('radio-check');
}else {
this.classList.add('radio-check');
}
}
</script>
</body>
</html>
思路2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input[type="radio"] {
-webkit-appearance: none;
width: 20px;
height: 20px;
border: 1px solid #666;
border-radius: 50%;
}
input[type="radio"]:checked{
background-color: red;
}
</style>
</head>
<body><input type="radio" id="boy" name="sex">
<label class="sex-label" for="boy" >男生</label>
<label class="sex-label" for="girl">女生</label>
<input type="radio" id="girl" name="sex">
</body>
</html>
- html自定义radio checkbox样式
- 自定义 checkbox, radio 样式
- html修改radio、checkbox样式
- 自定义checkbox和radio样式
- 实现自定义checkbox、radio样式
- HTML radio自定义美化样式。
- 【HTML】radio和checkbox样式美化
- html自定义checkbox、radio、select —— checkbox、radio篇
- 自定义radio与checkbox的样式
- ife系列之自定义checkbox、radio样式
- 自定义checkbox和radio的样式
- HTML 中自定义checkbox样式
- 更改checkbox默认样式、radio默认样式,CSS实现自定义
- radio与checkbox样式
- radio、checkbox样式修改
- angular 结合 css 用图片自定义radio及checkbox样式
- 纯css自定义radio,checkbox样式,提高用户体验
- html自定义checkbox、radio、select —— select篇
- (poj 3259)Wormholes(SPFA)
- 解决The SDK platform-tools version ((23)) is too old to check APIs compiled with API 23
- noip膜你赛day2第一题
- Leetcode—200.Number of Islands
- LCA板子
- html自定义radio checkbox样式
- HDU5102 Select 二分 思维
- Android编译错误:No rule to make target '/Android.mk'
- nginx反向代理用做域名转发
- 快捷的任务定义
- 用户点击回车键,模拟用户点击了登录按钮
- 应用微服务架构模式语言
- 详解ContextLoaderListener监听器的作用
- hdu Invade the Mars(侵入火星)