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. EOS dice移到1.8版本的修改汇总

    EOS dice移到1.8版本的修改汇总 1. CORE_SYMBOL 被去掉了,需要自己在文件中声明eg: uint64_t string_to_symbol_c(uint8_t precision ...

  2. 【Python之路】特别篇--Python面向对象(进阶篇)

    上一篇<Python 面向对象(初级篇)>文章介绍了面向对象基本知识: 面向对象是一种编程方式,此编程方式的实现是基于对 类 和 对象 的使用 类 是一个模板,模板中包装了多个“函数”供使 ...

  3. zabbix服务端接收的数据类型,便于编写脚本向服务端提交数据

    1.数据类型1:zabbix_agent执行脚本提交字典 UserParameter=tcp_port_listen,/usr/local/zabbix/share/script/get_game_p ...

  4. matplotlib中 plt.plot() 函数中**kwargs的参数形式

    plt.plot(x, y, **kwargs) **kwargs的参数大致有如下几种: color: 颜色 linestyle: 线条样式 marker: 标记风格 markerfacecolor: ...

  5. mac重启php7.0

    killall php-fpm /usr/local/opt/php70/sbin/php70-fpm restart

  6. jupyter工具

    国内源安装: pip install jupyter -i http://pypi.douban.com/simple --trusted-host pypi.douban.com pip --def ...

  7. thinkphp is NULL表达式写法

    thinkphp  中如果这样写 $where['status']=array('EQ','NULL'),打印出来sql是WHERE ( `status` = 'NULL' ):而我想要的是 `sta ...

  8. Android_(消息提示)多种使用Toast的消息提示

    Toast是一种提供给用户简介信息的视图,可以创建和显示消息,该视图以浮于应用程序之上的形式呈现给用户.因为它并不获得焦点,即使用户正在输入什么也不会受到影响. Toast目标是尽可能以不显眼的方式, ...

  9. java 包引入时*会全部加载吗

    有一个虚拟机参数: -XX:+TraceClassLoading 这两种写法,最终加载的类是一样的. 对比了一下输出的都是618行

  10. LC 163. Missing Ranges 【lock, hard】

    Given a sorted integer array nums, where the range of elements are in the inclusive range [lower, up ...