1. html代码

    <h2>你最喜欢的水果</h2>
    <div class="input-radio">
    <!-- 选中状态添加 checked 属性 -->
    <input id="apple" type="radio" name="fruits" checked />
    <label for="apple">苹果</label>
    </div>
    <div class="input-radio">
    <input id="banana" type="radio" name="fruits" />
    <label for="banana">香蕉</label>
    </div>
    <div class="input-radio">
    <input id="orange" type="radio" name="fruits" />
    <label for="orange">橙子</label>
    </div>
    <div class="input-radio">
    <input id="strawberry" type="radio" name="fruits" />
    <label for="strawberry">草莓</label>
    </div>

2.css代码

        .input-radio {
margin: 1em 0;
display:inline-block;
}
.input-radio input[type="radio"] {
opacity:;
}
.input-radio input[type="radio"] + label{
position: relative;
cursor: pointer;
}
.input-radio input[type="radio"] + label::before{
content: '';
position: absolute;
left: -24px;
border-radius: 50%;
width: 18px;
height: 18px;
border: 1px solid #999;
}
.input-radio input[type="radio"] + label::after{
content: '';
position: absolute;
left: -20px;
top: 4px;
border-radius: 50%;
width: 12px;
height: 12px;
}
.input-radio input[type="radio"]:checked + label::before{
border: 1px solid #24B7E5;
box-shadow: 0 0 6px #24B7E5;
transition: all .3s;
}
.input-radio input[type="radio"]:checked + label::after{
background:#24B7E5;
transition: all .5s;
}

3.效果

纯css实现单选框样式的更多相关文章

  1. vue.单选和多选,纯css自定义单选框样式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 用css实现html中单选框样式改变

     我们都知道,input的单选框是一个小圆框,不能直接更改样式.但是我们在很多网页中看到的单选框样式可不仅限于默认的那个样式(看上去没啥新意,也比较丑).那么,接下来我将介绍下如何实现该功能. 首先, ...

  3. 复选框、单选框样式自定义(https://www.cnblogs.com/freedom-feng/p/11346396.html)

    复选框.单选框样式自定义(https://www.cnblogs.com/freedom-feng/p/11346396.html)复选框html内容如下:<input type="c ...

  4. 纯css美化下拉框、复选框以及单选框样式并用jquery获取到其被选中的val

    具体样式如图所示: 注:获取val值时记得要先引入jquery库奥. 1.下拉框 css部分 #cargo_type_id{ font-size: 13px; border: solid 1px #b ...

  5. 纯css美化单选、复选框

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. js自定义修改复选框单选框样式,清除复选框单选框默认样式

    之前做项目的时候,也遇到过需要按照设计稿把<input type="checkbox">和<input type="radio">的默认 ...

  7. 使用checkbox实现纯CSS下拉框

    在这个例子中,我们会看到一个纯CSS制作的下拉框.主要是要用到了HTML元素的checkbox 和CSS3选择器,并没有用到JavaScript.例子如下: Click to Expand Link ...

  8. 纯css修改单选、复选按钮样式

    只支持IE9及以上 html <label><input class="radio" type="radio" name="radi ...

  9. css 单选框 样式 填充自定义背景 after

    input[type='radio'] //width 16px //height 16px display none //input[type='radio']:chcked // backgoun ...

随机推荐

  1. golang web实战之三(基于iris框架的 web小应用,数据库采用 sqlite3 )

    一.效果:一个图片应用 1.可上传图片到uploads目录. 2.可浏览和评论图片(用富文本编辑器输入) 二.梳理一下相关知识: 1.iris框架(模板输出,session) 2.富文本编辑器.sql ...

  2. 回文数二(acm训练)

    问题 1161: [回文数(二)] 时间限制: 1Sec 内存限制: 128MB 提交: 133 解决: 51 题目描述 若一个数(首位不为零)从左向右读与从右向左读都一样,我们就将其称之为回文数.  ...

  3. luoguP3373 【模板】线段树 2

    P3373 [模板]线段树 2 969通过 3.9K提交 题目提供者 HansBug 标签 云端↑ 难度 提高+/省选- 时空限制 1s / 128MB 题目描述 如题,已知一个数列,你需要进行下面两 ...

  4. matplotlib(二):折线图

    import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates # 解决中文显示问题 plt. ...

  5. 筛选前十按a-z顺序排

    需求: 从arr数组中筛选出num最多的前十个,若是最后几个num的值一样,则最后几个按字母a-z的顺序排序,最后取出num最大的前十个: var arr = [{"id":&qu ...

  6. 当 springboot 部署war包,tomcat报一堆无法解决的问题时

    直接打包 jar即可,这样就可以解决这些问题了.

  7. smarty中ifelse、foreach以及获取数组中键值名的一个实例

    <{if empty($history)}> <tr> <td colspan="6">Not any records!</td> ...

  8. PHP冒泡排序原生代码

    //冒泡排序 $arr=array(23,5,26,4,9,85,10,2,55,44,21,39,11,16,55,88,421,226,588); $n =count($arr); //echo ...

  9. SQL Server分页的存储过程写法以及性能比较

    ------创建数据库data_Test ----- create database data_Test GO use data_Test GO create table tb_TestTable - ...

  10. 堆排序 java

    <pre name="code" class="java">package heapSort; /** * 大根堆 * @author root * ...