forms.less 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. .labelHover() {
  2. &:hover {
  3. color: @grayLight;
  4. }
  5. }
  6. .radio, .checkbox {
  7. &-inline {
  8. padding-left: 0;
  9. &.highlight {
  10. left: -8px;
  11. }
  12. }
  13. // This handy trick allows us to make rules for .radio, .checkbox, .radio-inline, and, .checkbox-inline all at once.
  14. &, &-inline {
  15. // Sometimes the wrapping containter is a div with .checkbox or .radio, and has a label within it.
  16. // Sometimes the label itself is the wrapping container, and has .checkbox or .radio on it.
  17. // The use of the amperstand "parent selector" here allows us to cover many scenarios at once, with terse, but elegant, code.
  18. label&, .input-label&, & label, & .input-label {
  19. .labelHover;
  20. }
  21. label, .input-label, label& {
  22. cursor: pointer;
  23. font-weight: normal;
  24. .labelHover;
  25. }
  26. &.highlight {
  27. input:not(.sr-only) {
  28. & ~ label {
  29. padding: 4px;
  30. border-radius: @baseBorderRadius;
  31. }
  32. &:checked ~ label {
  33. background-color: #e9e9e9;
  34. opacity: 1;
  35. z-index: 0;
  36. }
  37. }
  38. }
  39. input:not(.sr-only) {
  40. position: absolute;
  41. width: 1px;
  42. height: 1px;
  43. margin: -1px;
  44. padding: 0;
  45. overflow: hidden;
  46. clip: rect(0,0,0,0);
  47. border: 0;
  48. & ~ label {
  49. padding-left: 0;
  50. &:before {
  51. font-family:"Glyphicons Halflings";
  52. font-style: normal;
  53. font-weight: normal;
  54. font-variant: normal;
  55. text-transform: none;
  56. line-height: 1;
  57. speak: none;
  58. border: 1px solid #adadad;
  59. color: #fff;
  60. font-size: 9px;
  61. width: 14px;
  62. height: 14px;
  63. padding: 0;
  64. margin-top: 0;
  65. margin-bottom: -2px;
  66. cursor: pointer;
  67. display: inline-block;
  68. z-index: 2;
  69. content: "";
  70. }
  71. }
  72. /* for keyboard tabbing */
  73. &:active ~ label, &:focus ~ label {
  74. color: @text-color;
  75. color: rgb(91, 157, 217);
  76. cursor: pointer;
  77. &:before {
  78. outline-color: rgb(91, 157, 217);
  79. outline-offset: -2px;
  80. outline-style: auto;
  81. outline-width: 5px;
  82. }
  83. &, &:hover {
  84. color: @text-color;
  85. cursor: pointer;
  86. }
  87. }
  88. &:active:hover ~ label, &:focus:hover ~ label, &:focus:hover ~ label, &:checked:hover ~ label {
  89. &, &:hover {
  90. color: @text-color;
  91. cursor: pointer;
  92. }
  93. }
  94. &[disabled="disabled"] {
  95. & ~ label, & ~ label:before {
  96. color: @text-color;
  97. opacity: 0.5 !important;
  98. cursor: not-allowed !important;
  99. }
  100. }
  101. &:checked ~ label {
  102. &:before {
  103. background: #39b3d7;
  104. border-color: #39b3d7;
  105. }
  106. }
  107. }
  108. &, &:hover {
  109. input {
  110. &:checked {
  111. }
  112. }
  113. }
  114. &.highlight {
  115. &:before {
  116. left: 4px;
  117. top: 7px;
  118. }
  119. }
  120. }
  121. &.highlight {
  122. input:not(.sr-only) {
  123. & ~ label {
  124. left: -8px;
  125. position: relative;
  126. }
  127. }
  128. }
  129. &-inline {
  130. padding-left: 0;
  131. &.highlight {
  132. // left: -8px;
  133. }
  134. &:before {
  135. left: 0;
  136. top: 3px;
  137. }
  138. }
  139. }