首页 > 其他分享 >css自定义复选框和单选框

css自定义复选框和单选框

时间:2023-04-06 10:25:56浏览次数:45  
标签:box checkbox 自定义 单选框 label gcs 20px border css

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <style type="text/css">
        *{margin:0;padding:0;box-sizing: border-box;}
        /*复选框*/
        .gcs-checkbox {
            display: none;
        }

        .gcs-checkbox+label {
            background-color: white;
            border-radius: 0px;
            border: 1px solid #d3d3d3;
            width: 20px;
            height: 20px;
            display: inline-block;
            text-align: center;
            vertical-align: bottom;
            line-height: 20px;
            box-sizing: border-box;
            margin-right:10px;
        }

        .gcs-checkbox+label:hover {
            cursor: pointer;
            border: 1px solid #2783FB;
        }

        .gcs-checkbox:checked+label {
            background-color: #eee;
            background: #2783FB;
        }

        .gcs-checkbox:checked+label:after {
            content: "\2714";
            color: white;
        }

        /*单选按钮*/

        .gcs-radio {
            display: none;
        }

        .gcs-radio+label {
            width: 20px;
            height: 20px;
            line-height: 16px;
            display: inline-block;
            text-align: center;
            vertical-align: bottom;
            border: 1px solid gray;
            border-radius: 50%;
            box-sizing: border-box;
            margin-right:10px;
        }

        .gcs-radio+label:hover {
            border: 1px solid #2783FB;
            cursor: pointer;
        }

        .gcs-radio:checked+label {
            background: #2783FB;
            border: 1px solid #2783FB;
        }

        .gcs-radio:checked+label:after {
            content: "\2022";
            font-size: 20px;
            color: white;
        }
    </style>

    <body>

        <h2>复选框</h2>
        <div>

            语文<input type="checkbox" id="语文" class="gcs-checkbox">
            <label for="语文"></label>
            数学<input type="checkbox" id="数学" class="gcs-checkbox">
            <label for="数学"></label>
            英语<input type="checkbox" id="英语" class="gcs-checkbox">

            <label for="英语"></label>

            计算机<input type="checkbox" id="计算机" class="gcs-checkbox">

            <label for="计算机"></label>

        </div> <br />

        <hr />

        <h2>单选按钮</h2>

        <div>

            男<input type="radio" name="sex" class="gcs-radio" id="man" />

            <label for="man"></label>

            女<input type="radio" name="sex" class="gcs-radio" id="woman" />

            <label for="woman"></label>

        </div>

        <hr />

    </body>

</html>
 

标签:box,checkbox,自定义,单选框,label,gcs,20px,border,css
From: https://www.cnblogs.com/xmyfsj/p/17291796.html

相关文章

  • 界面控件DevExtreme v23.1抢先体验,增强的UI/UX自定义功能!
    DevExtreme拥有高性能的HTML5/JavaScript小部件集合,使您可以利用现代Web开发堆栈(包括React,Angular,ASP.NETCore,jQuery,Knockout等)构建交互式的Web应用程序,该套件附带功能齐全的数据网格、交互式图表小部件、数据编辑器等。本文的目的就是为了让开发者预览即将发布的DevExtreme功......
  • React的行内样式与CSS
    如何为组件添加CSS的class?传递一个字符串作为className属性:render(){return<spanclassName="menunavigation-menu">Menu</span>}CSS的class依赖组件的props或state的情况很常见:render(){letclassName='menu';if(this.props.isActive)......
  • CSS笔记(待完善)
    CSS笔记css权重ID(100)>class(10)>element(1)css最高权重!important块元素(block)可以设置宽度和高度,独立成行。h1~h6、p、div、ul、li行内元素(内联元素、块级元素)(inline)不可以设置宽度和高度,不独立成行a、span行内块元素(inline-block)可以设置宽度和高度,不独立......
  • uni-app:ios/android中的nvue和vue页面加载自定义字体(hbuilderx 3.7.3)
    一,官方文档地址:https://uniapp.dcloud.net.cn/tutorial/nvue-api.html#addrule二,代码1,nvue页面:模板<viewclass="listTitle">{{item.title}}</view>......
  • 设计模式(三十二)----综合应用-自定义Spring框架-自定义Spring IOC-自定义Spring IOC
    1自定义SpringIOC总结1.1使用到的设计模式工厂模式。这个使用工厂模式+配置文件的方式。单例模式。SpringIOC管理的bean对象都是单例的,此处的单例不是通过构造器进行单例的控制的,而是spring框架对每一个bean只创建了一个对象。模板方法模式。AbstractApplicationC......
  • python-爬虫-css提取-写入csv-爬取猫眼电影榜单
    猫眼有一个电影榜单top100,我们将他的榜单电影数据(电影名、主演、上映时间、豆瓣评分)抓下来保存到本地的excle中本案例使用css方式提取页面数据,所以会用到以下库importtimeimportrequestsimportparsel#解析库,解析cssimportcsv#爬取的数据写入csv创建csv文件标头信息......
  • 前端开发-CSS
    三种CSS写法1.在标签内书写2.在head中书写3.在外部文件书写 各种选择器常用:类选择器,标签选择器,后代选择器少用:ID选择器,属性选择器    多个样式覆盖问题:1.样式不同时一起作用2.样式相同时,取style中排序后面的3.若要强制使用,则添加important,如color:red!imp......
  • uni-app:tabbar自定义中间凸起按钮的tabbar(hbuilderx 3.7.3)
    一,官方文档地址:https://uniapp.dcloud.net.cn/collocation/pages.html#tabbarhttps://uniapp.dcloud.net.cn/api/ui/tabbar.html#ontabbarmidbuttontap二,代码1,pages.json"tabBar":{"color":"#7A7E83",//字体颜色"sel......
  • shared_ptr 自定义 deleter 删除器
    make_shared不支持自定义删除器shared_ptr<Bar>sp2(sp1,deleter1);无法指定自定义删除器?《C++Primer5th》P413错误?sp1不能是智能指针,可以是内置指针reset参数为内置指针,可以重新指定删除器测试代码classBar{public:Bar(intii):i(ii){cout<<......
  • python flask 框架后端如何获取前端的表单数据 文本 单选框 多选框
    文本pyhon后端用request.values.get("name")去获取  if request.method == "POST":        username = request.values.get("username")     sex = request.values.get("sex") 二、多选按钮checkbox  <......