css 设置 checkbox复选框控件的对勾√样式

css 设置 checkbox复选框控件的对勾√样式

最终的样式,想要的效果:
技术分享
 

我们要创建方框中的对勾,对于这一点,我们可以使用伪类创建一个新的元素,为了实现这个样式,我们可以创建一个5px * 15px的长方形并给他加上边框。这时候我们去掉上面和右边的边框之后,它会看起来像一个字母L。然后我们可以使用CSS的属性让它旋转一下,这样看起来就像是一个对勾。

    1. lang="en">
    2. charset="UTF-8">
    3. <span class="pln"><span class="pln">选中标签forcheck<span class="tag"><span class="tag">
    4. type="text/css">
    5. .div-checked label {
    6. cursor: pointer;
    7. position: relative;
    8. display: inline-block;
    9. width: 150px;
    10. height: 38px;
    11. border: 1px solid grey;
    12. }
    13. /**
    14. * 按钮透明
    15. * @type {String}
    16. */
    17. input[type="checkbox"] {
    18. opacity: 0;
    19. }
    20. /**
    21. * checkbox选中样式
    22. * @type {String}
    23. */
    24. input[type="checkbox"]:checked + i {
    25. border-color: blue;
    26. color: blue;
    27. }
    28. /**
    29. * i标签的大小
    30. */
    31. i {
    32. position: absolute;
    33. top: 0;
    34. left: 0;
    35. width: 100%;
    36. height: 100%;
    37. border: 1px solid #ccc;
    38. text-align: center;
    39. line-height: 36px;
    40. }
    41. /**
    42. * 对勾√效果,使用border
    43. * @type {[type]}
    44. */
    45. span:after {
    46. opacity: 1;
    47. content: ‘‘;
    48. position: absolute;
    49. width: 5px;
    50. height: 15px;
    51. background: transparent;
    52. top: 10px;
    53. right: 5px;
    54. border: 2px solid #fff;
    55. border-top: none;
    56. border-left: none;
    57. -webkit-transform: rotate(35deg);
    58. -moz-transform: rotate(35deg);
    59. -o-transform: rotate(35deg);
    60. -ms-transform: rotate(35deg);
    61. transform: rotate(35deg);
    62. }
    63. /**
    64. * 选中状态,span(三角形)样式
    65. * @type {String}
    66. */
    67. input[type="checkbox"]:checked + i + span {
    68. width: 0px;
    69. height: 0px;
    70. border-color: blue transparent;
    71. border-width: 0px 0px 30px 30px;
    72. border-style: solid;
    73. position: absolute;
    74. right: -1px;
    75. top: 10px;
    76. opacity: 1;
    77. }
    78. }
    79. }
    80. class="div-checked">
    81. type="checkbox" value="cbEticket">
    82. 电子票
    83. type="checkbox" checked="" value="cbMeetingRemind">
    84. 会议提醒
  •  

    css 设置 checkbox复选框控件的对勾√样式

    标签:border   absolute   poi   nbsp   inpu   oct   中标   inline   bsp   

    原文地址:http://www.cnblogs.com/liusc/p/57c27a929622b8de72155d98888f67cc.html

    转载于:https://www.cnblogs.com/xiaoshen666/p/10721404.html

    你可能感兴趣的:(css 设置 checkbox复选框控件的对勾√样式)