checkbox.scss 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**Variable**/
  2. @import './helpers/mixin.scss';
  3. @import './base/common.scss';
  4. /*checkbox-group*/
  5. .vxe-checkbox-group {
  6. display: inline-block;
  7. vertical-align: middle;
  8. line-height: 1;
  9. }
  10. /*checkbox*/
  11. .vxe-checkbox {
  12. display: inline-block;
  13. vertical-align: middle;
  14. white-space: nowrap;
  15. user-select: none;
  16. line-height: 1;
  17. cursor: pointer;
  18. &+.vxe-checkbox {
  19. margin-left: 10px;
  20. }
  21. > input {
  22. &[type="checkbox"] {
  23. position: absolute;
  24. width: 0;
  25. height: 0;
  26. border: 0;
  27. appearance: none;
  28. }
  29. &+.vxe-checkbox--icon {
  30. position: relative;
  31. display: inline-block;
  32. width: 1em;
  33. height: 1em;
  34. background-color: $vxe-checkbox-icon-background-color;
  35. vertical-align: middle;
  36. border-radius: $vxe-checkbox-border-radius;
  37. border: $vxe-checkbox-border-width solid $vxe-input-border-color;
  38. &:before {
  39. content: "";
  40. position: absolute;
  41. }
  42. }
  43. &:checked+.vxe-checkbox--icon {
  44. background-color: $vxe-primary-color;
  45. border-color: $vxe-primary-color;
  46. &:before {
  47. height: $vxe-checkbox-checked-height;
  48. width: $vxe-checkbox-checked-width;
  49. left: 50%;
  50. top: 50%;
  51. border: $vxe-checkbox-border-width solid $vxe-checkbox-checked-icon-border-color;
  52. border-left: 0;
  53. border-top: 0;
  54. transform: translate(-50%, -50%) rotate(45deg);
  55. }
  56. &+.vxe-checkbox--label {
  57. color: $vxe-primary-color;
  58. }
  59. }
  60. }
  61. &.is--indeterminate {
  62. > input {
  63. &:not(:checked) {
  64. &+.vxe-checkbox--icon {
  65. background-color: $vxe-primary-color;
  66. border-color: $vxe-primary-color;
  67. &:before {
  68. border: 0;
  69. left: 50%;
  70. top: 50%;
  71. height: $vxe-checkbox-indeterminate-height;
  72. width: $vxe-checkbox-indeterminate-width;
  73. background-color: $vxe-checkbox-indeterminate-icon-background-color;
  74. transform: translate(-50%, -50%);
  75. }
  76. }
  77. }
  78. }
  79. }
  80. &:not(.is--disabled) {
  81. & > input {
  82. &:focus {
  83. &+.vxe-checkbox--icon {
  84. border-color: $vxe-primary-color;
  85. box-shadow: 0 0 0.2em 0 $vxe-primary-color;
  86. }
  87. }
  88. }
  89. &:hover {
  90. > input {
  91. &+.vxe-checkbox--icon {
  92. border-color: $vxe-primary-color;
  93. }
  94. }
  95. }
  96. }
  97. &.is--disabled {
  98. cursor: not-allowed;
  99. > input {
  100. &+.vxe-checkbox--icon {
  101. border-color: $vxe-input-disabled-color;
  102. background-color: $vxe-input-disabled-background-color;
  103. &:before {
  104. border-color: $vxe-primary-disabled-color;
  105. }
  106. &+.vxe-checkbox--label {
  107. color: $vxe-disabled-color;
  108. }
  109. }
  110. &:checked+.vxe-checkbox--icon {
  111. border-color: $vxe-input-disabled-color;
  112. background-color: $vxe-input-disabled-background-color;
  113. }
  114. }
  115. }
  116. .vxe-checkbox--label {
  117. padding-left: 0.5em;
  118. vertical-align: middle;
  119. display: inline-block;
  120. max-width: 50em;
  121. @extend %TextEllipsis;
  122. }
  123. }
  124. .vxe-checkbox {
  125. font-size: $vxe-font-size;
  126. .vxe-checkbox--icon {
  127. font-size: $vxe-checkbox-font-size-default;
  128. }
  129. &.size--medium {
  130. font-size: $vxe-font-size-medium;
  131. .vxe-checkbox--icon {
  132. font-size: $vxe-checkbox-font-size-medium;
  133. }
  134. }
  135. &.size--small {
  136. font-size: $vxe-font-size-small;
  137. .vxe-checkbox--icon {
  138. font-size: $vxe-checkbox-font-size-small;
  139. }
  140. }
  141. &.size--mini {
  142. font-size: $vxe-font-size-mini;
  143. .vxe-checkbox--icon {
  144. font-size: $vxe-checkbox-font-size-mini;
  145. }
  146. }
  147. }