index.less 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @radio-prefix-cls: ~'@{ant-prefix}-radio';
  4. @radio-group-prefix-cls: ~'@{radio-prefix-cls}-group';
  5. @radio-inner-prefix-cls: ~'@{radio-prefix-cls}-inner';
  6. @radio-duration: 0.3s;
  7. @radio-focus-shadow: 0 0 0 3px @slider-handle-color-focus-shadow;
  8. @radio-button-focus-shadow: @radio-focus-shadow;
  9. .@{radio-group-prefix-cls} {
  10. .reset-component();
  11. display: inline-block;
  12. font-size: 0;
  13. .@{ant-prefix}-badge-count {
  14. z-index: 1;
  15. }
  16. > .@{ant-prefix}-badge:not(:first-child) > .@{radio-prefix-cls}-button-wrapper {
  17. border-left: none;
  18. }
  19. }
  20. // 一般状态
  21. .@{radio-prefix-cls}-wrapper {
  22. .reset-component();
  23. position: relative;
  24. display: inline-flex;
  25. align-items: baseline;
  26. margin-right: @radio-wrapper-margin-right;
  27. cursor: pointer;
  28. &-disabled {
  29. cursor: not-allowed;
  30. }
  31. &::after {
  32. display: inline-block;
  33. width: 0;
  34. overflow: hidden;
  35. content: '\a0';
  36. }
  37. &&-in-form-item {
  38. input[type='radio'] {
  39. width: 14px;
  40. height: 14px;
  41. }
  42. }
  43. }
  44. .@{radio-prefix-cls} {
  45. .reset-component();
  46. position: relative;
  47. top: @radio-top;
  48. display: inline-block;
  49. outline: none;
  50. cursor: pointer;
  51. .@{radio-prefix-cls}-wrapper:hover &,
  52. &:hover .@{radio-inner-prefix-cls},
  53. &-input:focus + .@{radio-inner-prefix-cls} {
  54. border-color: @radio-dot-color;
  55. }
  56. &-input:focus + .@{radio-inner-prefix-cls} {
  57. box-shadow: @radio-focus-shadow;
  58. }
  59. &-checked::after {
  60. position: absolute;
  61. top: 0;
  62. left: 0;
  63. width: 100%;
  64. height: 100%;
  65. border: 1px solid @radio-dot-color;
  66. border-radius: 50%;
  67. visibility: hidden;
  68. animation: antRadioEffect 0.36s ease-in-out;
  69. animation-fill-mode: both;
  70. content: '';
  71. }
  72. &:hover::after,
  73. .@{radio-prefix-cls}-wrapper:hover &::after {
  74. visibility: visible;
  75. }
  76. &-inner {
  77. &::after {
  78. position: absolute;
  79. top: 50%;
  80. left: 50%;
  81. display: block;
  82. width: @radio-size;
  83. height: @radio-size;
  84. margin-top: -(@radio-size / 2);
  85. margin-left: -(@radio-size / 2);
  86. background-color: @radio-dot-color;
  87. border-top: 0;
  88. border-left: 0;
  89. border-radius: @radio-size;
  90. transform: scale(0);
  91. opacity: 0;
  92. transition: all @radio-duration @ease-in-out-circ;
  93. content: ' ';
  94. }
  95. position: relative;
  96. top: 0;
  97. left: 0;
  98. display: block;
  99. width: @radio-size;
  100. height: @radio-size;
  101. background-color: @radio-button-bg;
  102. border-color: @border-color-base;
  103. border-style: solid;
  104. border-width: @radio-border-width;
  105. border-radius: 50%;
  106. transition: all @radio-duration;
  107. }
  108. &-input {
  109. position: absolute;
  110. top: 0;
  111. right: 0;
  112. bottom: 0;
  113. left: 0;
  114. z-index: 1;
  115. cursor: pointer;
  116. opacity: 0;
  117. }
  118. &&-disabled {
  119. .@{radio-inner-prefix-cls} {
  120. border-color: @border-color-base;
  121. }
  122. }
  123. }
  124. // 选中状态
  125. .@{radio-prefix-cls}-checked {
  126. .@{radio-inner-prefix-cls} {
  127. border-color: @radio-dot-color;
  128. &::after {
  129. transform: scale((unit(@radio-dot-size) / unit(@radio-size)));
  130. opacity: 1;
  131. transition: all @radio-duration @ease-in-out-circ;
  132. }
  133. }
  134. }
  135. .@{radio-prefix-cls}-disabled {
  136. cursor: not-allowed;
  137. .@{radio-inner-prefix-cls} {
  138. background-color: @input-disabled-bg;
  139. cursor: not-allowed;
  140. &::after {
  141. background-color: @radio-dot-disabled-color;
  142. }
  143. }
  144. .@{radio-prefix-cls}-input {
  145. cursor: not-allowed;
  146. }
  147. & + span {
  148. color: @disabled-color;
  149. cursor: not-allowed;
  150. }
  151. }
  152. span.@{radio-prefix-cls} + * {
  153. padding-right: 8px;
  154. padding-left: 8px;
  155. }
  156. .@{radio-prefix-cls}-button-wrapper {
  157. position: relative;
  158. display: inline-block;
  159. height: @btn-height-base;
  160. margin: 0;
  161. padding: 0 @radio-button-padding-horizontal;
  162. color: @radio-button-color;
  163. font-size: @font-size-base;
  164. line-height: @btn-height-base - 2px;
  165. background: @radio-button-bg;
  166. border: @border-width-base @border-style-base @border-color-base;
  167. // strange align fix for chrome but works
  168. // https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
  169. border-top-width: @border-width-base + 0.02px;
  170. border-left-width: 0;
  171. cursor: pointer;
  172. transition: color 0.3s, background 0.3s, border-color 0.3s, box-shadow 0.3s;
  173. a {
  174. color: @radio-button-color;
  175. }
  176. > .@{radio-prefix-cls}-button {
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. z-index: -1;
  181. width: 100%;
  182. height: 100%;
  183. }
  184. .@{radio-group-prefix-cls}-large & {
  185. height: @input-height-lg;
  186. font-size: @font-size-lg;
  187. line-height: @input-height-lg - 2px;
  188. }
  189. .@{radio-group-prefix-cls}-small & {
  190. height: @input-height-sm;
  191. padding: 0 @control-padding-horizontal-sm - 1px;
  192. line-height: @input-height-sm - 2px;
  193. }
  194. &:not(:first-child) {
  195. &::before {
  196. position: absolute;
  197. top: @border-width-base * -1;
  198. left: -1px;
  199. display: block;
  200. box-sizing: content-box;
  201. width: 1px;
  202. height: 100%;
  203. padding: @border-width-base 0;
  204. background-color: @border-color-base;
  205. transition: background-color 0.3s;
  206. content: '';
  207. }
  208. }
  209. &:first-child {
  210. border-left: @border-width-base @border-style-base @border-color-base;
  211. border-radius: @border-radius-base 0 0 @border-radius-base;
  212. }
  213. &:last-child {
  214. border-radius: 0 @border-radius-base @border-radius-base 0;
  215. }
  216. &:first-child:last-child {
  217. border-radius: @border-radius-base;
  218. }
  219. &:hover {
  220. position: relative;
  221. color: @radio-dot-color;
  222. }
  223. &:focus-within {
  224. box-shadow: @radio-button-focus-shadow;
  225. }
  226. .@{radio-prefix-cls}-inner,
  227. input[type='checkbox'],
  228. input[type='radio'] {
  229. width: 0;
  230. height: 0;
  231. opacity: 0;
  232. pointer-events: none;
  233. }
  234. &-checked:not(&-disabled) {
  235. z-index: 1;
  236. color: @radio-dot-color;
  237. background: @radio-button-checked-bg;
  238. border-color: @radio-dot-color;
  239. &::before {
  240. background-color: @radio-dot-color;
  241. }
  242. &:first-child {
  243. border-color: @radio-dot-color;
  244. }
  245. &:hover {
  246. color: @radio-button-hover-color;
  247. border-color: @radio-button-hover-color;
  248. &::before {
  249. background-color: @radio-button-hover-color;
  250. }
  251. }
  252. &:active {
  253. color: @radio-button-active-color;
  254. border-color: @radio-button-active-color;
  255. &::before {
  256. background-color: @radio-button-active-color;
  257. }
  258. }
  259. &:focus-within {
  260. box-shadow: @radio-button-focus-shadow;
  261. }
  262. }
  263. .@{radio-group-prefix-cls}-solid &-checked:not(&-disabled) {
  264. color: @radio-solid-checked-color;
  265. background: @radio-dot-color;
  266. border-color: @radio-dot-color;
  267. &:hover {
  268. color: @radio-solid-checked-color;
  269. background: @radio-button-hover-color;
  270. border-color: @radio-button-hover-color;
  271. }
  272. &:active {
  273. color: @radio-solid-checked-color;
  274. background: @radio-button-active-color;
  275. border-color: @radio-button-active-color;
  276. }
  277. &:focus-within {
  278. box-shadow: @radio-button-focus-shadow;
  279. }
  280. }
  281. &-disabled {
  282. color: @disabled-color;
  283. background-color: @input-disabled-bg;
  284. border-color: @border-color-base;
  285. cursor: not-allowed;
  286. &:first-child,
  287. &:hover {
  288. color: @disabled-color;
  289. background-color: @input-disabled-bg;
  290. border-color: @border-color-base;
  291. }
  292. &:first-child {
  293. border-left-color: @border-color-base;
  294. }
  295. }
  296. &-disabled&-checked {
  297. color: @radio-disabled-button-checked-color;
  298. background-color: @radio-disabled-button-checked-bg;
  299. border-color: @border-color-base;
  300. box-shadow: none;
  301. }
  302. }
  303. @keyframes antRadioEffect {
  304. 0% {
  305. transform: scale(1);
  306. opacity: 0.5;
  307. }
  308. 100% {
  309. transform: scale(1.6);
  310. opacity: 0;
  311. }
  312. }
  313. @import './rtl';