经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTMLCSS » CSS » 查看文章
自定义checkbox样式
来源:cnblogs  作者:冰雪Queen  时间:2018/10/22 16:10:05  对本文有异议

通过选中时添加背景图片自定义CheckBox样式

效果:

CSS样式:

 

  1. <style type="text/css>
  2. label {
  3. width: 10%;
  4. display: flex;
  5. display: -webkit-flex;
  6. display: -moz-flex;
  7. flex-direction: row;
  8. justify-content: center;
  9. align-items: center;
  10. }
  11. label input[type=checkbox] {
  12. width: 15px;
  13. height: 15px;
  14. overflow: hidden;
  15. background: #fff;
  16. appearance: none;
  17. -webkit-appearance: none;
  18. border: 1px solid #808080;
  19. outline: none;
  20. margin-right: 5px;
  21. margin-top: 0;
  22. }
  23. input[type=checkbox]:checked {
  24. appearance: none;
  25. -webkit-appearance: none;
  26. background-image: url(./Images/btn-blue_03.png);
  27. background-position: center;
  28. background-repeat: no-repeat;
  29. background-size: 100%;
  30. border-radius: 4px;
  31. border: 0;
  32. overflow: hidden;
  33. }
  34. </style>

 

  

 

html结构:
  1. <body>
  2.   <label>
  3.     <input type="checkbox" name="type" checked>
  4.     <span>one</span>
  5.   </label>
  6.   <label>
  7.     <input type="checkbox" name="type">
  8.     <span>two</span>
  9.   </label>
  10. </body> 

  

 
 

 

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号