html自带的选择框样式不好看,并且在ios设备上丑的罚款。所以一般都是自定义样式;

原理:将原来默认的input选择框隐藏,然后控制label的:before与:after,配合矢量图标或者图片来实现选中效果。

由于时间原因,只做了个一种样式。想要其他样式的话改改就行了。想看更详细的给大家推荐个网址可以详细看看:http://www.jq22.com/yanshi11319

效果:

  

这些样式大小、颜色、图标都是可以改的啦。有时间要做一套出来,可以直接用的啦。建议用图片做,如果用矢量图标的话效果虽然好,但是要引入图标库并且有点小问题。

html代码:

<link rel="stylesheet" href="http://at.alicdn.com/t/font_bo8heq56fci60f6r.css">
<p class="checkbox"><input id="agree_check" type="checkbox"><label for="agree_check">我已阅读并同意<a href="user_agreement.html" target="_blank"><span class="blue">《软件使用协议》</span></a></label></p>
<p class="tc mt10"><button class="btn_submit" @click="_submit()">立即分享</button></p>
<div class="radiobox"><input type="radio" id="nan" name="sex" value="1" v-model="sex" /><label for="nan">男</label>
</div>
<div class="radiobox">
    <input type="radio" id="nv" name="sex" value="2" v-model="sex" /><label for="nv">女</label>
</div>

css样式:

/*复选框样式*/
.checkbox{position:relative;}
.checkbox label{padding-left:18px;}
.checkbox label::before {content: "";display: inline-block;position: absolute;width: 17px;height: 17px;left: 0;top:1px;margin-left: 12px;border: 1px solid #cccccc;border-radius: 3px;background-color: #fff;}.checkbox label::after {content: "";display: inline-block;position: absolute;width: 16px;height: 16px;left: -2px;top: 0px;margin-left: 12px;padding-left: 3px;padding-top: 1px;font-size: 16px;color: #555555;}.checkbox input[type="checkbox"]:checked + label::before {background-color: #337ab7;border-color: #337ab7;background-image:;}.checkbox input[type="checkbox"]:checked + label:after{
background:url(../img/checked.png) 2px 1px;
background-size:100% 100%;

}/*单选框样式*/
.radiobox {padding-left: 40px; display:inline-block;}
.radiobox label {display: inline-block;vertical-align: middle;position: relative;padding-left: 5px;line-height:19px; }
.radiobox label::before {content: "";display: inline-block;position: absolute;width: 17px;height: 17px;left: 0;margin-left: -15px;border: 1px solid #cccccc;border-radius: 50%;background-color: #fff;-webkit-transition: border 0.15s ease-in-out;-o-transition: border 0.15s ease-in-out;transition: border 0.15s ease-in-out; }
.radiobox label::after {display: inline-block;position: absolute;content: " ";width: 11px;height: 11px;left: 3px;top: 3px;margin-left: -15px;border-radius: 50%;background-color: #555555;-webkit-transform: scale(0, 0);-ms-transform: scale(0, 0);-o-transform: scale(0, 0);transform: scale(0, 0);-webkit-transition: -webkit-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);-moz-transition: -moz-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);-o-transition: -o-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);transition: transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33); }
.radiobox input[type="radio"] {opacity: 0;z-index: 1; }.radiobox input[type="radio"]:checked + label::after {-webkit-transform: scale(1, 1);-ms-transform: scale(1, 1);-o-transform: scale(1, 1);transform: scale(1, 1); }
.radiobox input[type="radio"]:disabled + label {opacity: 0.65; }
.radiobox input[type="radio"]:disabled + label::before {cursor: not-allowed; }
.radiobox.radio-inline {margin-top: 0; }.radiobox input[type="radio"] + label::after {background-color: #337ab7; }

转载于:https://www.cnblogs.com/LChenglong/p/7181795.html

input选择框样式修改与自定义相关推荐

  1. html input选择框样式修改,关于type=file的input框样式修改小结

    关于type="file"的input是啥? 这个是啥我觉得没必要再说了,反正大家都知道,然后在现在有各种手机的时代,还可以通过直接拍照的方式来上传,反正比以前好玩多了. 上传按钮 ...

  2. html5 input搜索框样式修改,修改input搜索框默认叉号的样式为自定义图片

    兼容IE的自定义input搜索框叉号样式(使用图片替换input原生叉号) 代码 input::-webkit-search-cancel-button { -webkit-appearance: n ...

  3. html input type=quot;filequot;,科技常识:关于type=quot;filequot;的input框样式修改小结...

    今天小编跟大家讲解下有关关于type="file"的input框样式修改小结 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关关于type="file" ...

  4. input 选择框改变背景小技巧

    最近在项目中遇到一个问题,想要改变input选择框的背景,然而,令我没有想到的是,竟然无法直接改变背景的颜色 通常情况下:我们都可以通过改变元素的 background-color 的值来改变元素的背 ...

  5. vue-element-ui的各种弹出框样式修改

    vue-element-ui的弹出框与#app同级,以下为各种弹出框样式修改方式: 1.组件中存在popper-append-to-body属性 2.使用popper-class属性修改弹出框样式 3 ...

  6. Input placeholder属性样式修改(颜色,大小,位置)

    Input placeholder属性样式修改(颜色,大小,位置) input::-webkit-input-placeholder {/* placeholder颜色 */color: #aab2b ...

  7. uni-app开发:(源码级别)uni-badge样式修改(自定义插槽)

    文章目录 uni-app开发:(源码级别)uni-badge样式修改(自定义插槽) 一.效果图需求说明: 二.源码 · 修改前后对比: 2.1. 修改前 2.2. 修改后 三.调用代码: 附件:uni ...

  8. html input文本框样式,css设置input文本框样式代码实例_html/css_WEB-ITnose

    css设置input文本框样式代码实例: 使用css设置input元素的样式是最为常用的操作之一,当然也是最为基础的操作,可能对于刚刚接触css的朋友还不够熟悉,下面就通过一段简单的代码历史演示一下如 ...

  9. 用jquery修改默认的单选框radio或者复选框checkbox选择框样式

    默认的radio和checkbox选框很难看.我去看了一下qq注册的页面.发现单选和复选框并没有用<input>,居然是用是A标签.然后用css背景图片展示选择框,用JavaScript控 ...

最新文章

  1. 精通python网络爬虫-精通Python网络爬虫:核心技术、框架与项目实战 PDF
  2. Office协同办公:SkyDrive
  3. 在线IDE之关键字另色显示
  4. 【Python】参考ggplot2,Seaborn将迎来超大版本更新!
  5. mysql分页查询limit_MySQL查询语句(where,group by,having,order by,limit)
  6. jmeter通过ant执行时报错 jmeter.log not found
  7. MySQL高可用实现:主从结构下ProxySQL中的读写分离
  8. Python基础——全局变量与局部变量
  9. 深入理解Java虚拟机——VisualVM工具的下载及安装
  10. 【精华】拒绝国外IP海外IP访问的几种方法
  11. USB转串口那些事儿—串口驱动类型
  12. OTT盒子市场起量正当时 12家主控厂商争夺3000万市场
  13. 华尔街追逐中国机遇,阿里巴巴收盘价创下历史新高
  14. 关于Faster-RCNN
  15. mybatis学习4
  16. windows CMD命令大全及详细解释和语法
  17. 腾讯游戏天美工作室实习感悟
  18. 旅游类App的原型制作分享
  19. 安卓开发的一些uuid,imei,meid,imsi,clientid,uuid
  20. java内存修改_修改java虚拟机启动内存大小

热门文章

  1. 利盟 x466 双面打印问题之正反面颠倒
  2. 第1113期AI100_机器学习日报(2017-10-05)
  3. 科幻迷福利-黑客帝国4明年1.14
  4. 第21课 机灵的小老鼠
  5. BIDI单纤双向光模块
  6. 程序员大佬都在用的代码编辑器,你不用就OUT啦
  7. call和apply详解-利用借充电宝模拟用法
  8. SpringMvc学习日记-基础知识
  9. idea修改回默认字体_设置 IntelliJ IDEA 主题和字体的方法
  10. 【PWN系列】2015-Defcon Qualifier R0pbaby