使用CSS修改radio样式

1,第一种样式:

 <label> <input class="radio_type" type="radio"/>免费</label>
 <label> <input class="radio_type" type="radio" />积分</label>
 <label> <input class="radio_type" type="radio" />现金</label>
.radio_type {
    width: 20px;
    height: 20px;
    appearance: none;
    position: relative;
    outline: none;
}
.radio_type:before {
    content: "";
    width: 15px;
    height: 15px;
    border: 1px solid #19874f;
    display: inline-block;
    border-radius: 50%;
    vertical-align: middle;
}
.radio_type:checked:before {
    content: "";
    width: 15px;
    height: 15px;
    border: 1px solid #19874f;
    display: inline-block;
    border-radius: 50%;
    vertical-align: middle;
}
.radio_type:checked:after {
    content: "";
    width: 9px;
    height: 9px;
    text-align: center;
    background: #19874f;
    border-radius: 50%;
    display: block;
    position: absolute;
    top: 4px;
    left: 4px;
}
.radio_type:checked + label {
    color: #edd19d;
}

第二种样式:

<input class="radio_type" type="radio" name="type" id="radio1" checked="checked"/>
<label for="radio1">radio1</label>
<input class="radio_type" type="radio" name="type" id="radio2" />
<label for="radio2">radio2</label>
label{
    line-height: 20px;
    display: inline-block;
    margin-left: 5px;
    margin-right:15px;
    color: #777;
}
.radio_type{
    width: 20px;
    height: 20px;
    appearance: none;
    position: relative;
}
.radio_type:before{
    content: ‘‘;
    width: 20px;
    height: 20px;
    border: 1px solid #7d7d7d;
    display: inline-block;
    border-radius: 50%;
    vertical-align: middle;
}
.radio_type:checked:before{
    content: ‘‘;
    width: 20px;
    height: 20px;
    border: 1px solid #c59c5a;
    background:#c59c5a;
    display: inline-block;
    border-radius: 50%;
    vertical-align: middle;
}
.radio_type:checked:after{
    content: ‘‘;
    width: 10px;
    height:5px;
    border: 2px solid white;
    border-top: transparent;
    border-right: transparent;
    text-align: center;
    display: block;
    position: absolute;
    top: 6px;
    left:5px;
    vertical-align: middle;
    transform: rotate(-45deg);
}
.radio_type:checked+label{
    color: #c59c5a;
}

参考:https://www.jianshu.com/p/e1dac58adb2c

原文地址:https://www.cnblogs.com/lovebear123/p/12074682.html

时间: 2024-07-31 16:34:32

使用CSS修改radio样式的相关文章

纯css修改radio样式

<!DOCTYPE html> <html> <head> <title>radio demo</title> <style> div,ul,li { padding: 0; margin: 0; } li { position: relative; height: 30px; margin-bottom: 10px; } .my-radio { position: relative; z-index: 1; } .my-radio:

css修改滚动条样式

<div class="inner"> <div class="innerbox"> <p style="height:200px;">这是内容111</p> <p style="height:400px;">这里是内容222</p> <p>这里是内容333</p> </div> </div> css .in

CSS修改Autocomplete样式

举个场景:在用户登录成功的时候,浏览器有时候会咨询你是否记住密码,当你记住密码下次登录的时候,标签会自动填充,但是这样会造成样式不统一,解决办法如下: input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus input:-webkit-autofill, textarea:-webkit-autofill, textarea:-webkit-autofill:hover textarea

css 修改placeholder样式

input::-webkit-input-placeholder{ color:red; } input::-moz-placeholder{ /* Mozilla Firefox 19+ */ color:red; } input:-moz-placeholder{ /* Mozilla Firefox 4 to 18 */ color:red; } input:-ms-input-placeholder{ /* Internet Explorer 10-11 */ color:red; }

radio checkbox 修改默认样式

1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <title>radio与checbox修改默认样式</title> 7 <style> 8 body{font-size: 12px;} 9 /*radio*/ 10 11 .radio-input label { font-weig

CSS定义Radio单选项和Checkbox复选框样式有效代码

我们都知道一般情况利用css来定义Radio单选项和Checkbox复选框样式是无效的,下面我来给大家介绍利用CSS定义Radio单选项和Checkbox复选框样式,有需要了解的朋友可参考. 完全使用css来实例 复制代码 代码如下: <style type=”text/css”> form#form1 {font:12px tahoma,sans-serif} input[type="checkbox"] {visibility:hidden;width:0;height

CSS 修改 IOS 默认按钮样式

不知道大家在做移动端页面的时候有没遇到过在 IOS 端 一些按钮显示和安卓的截然不同,今天下午又有一个小伙在群里问这个问题.我记得之前我也遇到过,今天给大家分享一下怎么使用 CSS修改IOS的默认样式. ======================================================== 小月博客 http://www.aliyue.net WEB ======================================================== 第一:

修改手机端radio 样式

实现手机端radio样式修改 http://www.iconfont.cn/搜索对勾图片和圆圈图,分别命名为radio.png 和 select.png 填写自己要的颜色,点击下载png,一般人都会 <span class="address-radio checked"></span> <input type="radio" name="address" class="hide"> .add

css input checkbox和radio样式美化

css input checkbox和radio样式美化 2014年9月1日 132495次浏览 在之前的一篇文章中,我已经介绍了input file上传按钮的美化,地址:http://www.haorooms.com/post/css_input_uploadmh ,今天,我们来讲一下checkbox美化和radio美化,关于select下拉框的美化的话,要用一个jquery插件了,这个插件后面我们再讲!急用的同学可以留言! 但是像checkbox美化和radio美化,input美化,根本就不