ant-design/components/checkbox/style/mixin.less

208 lines
4.8 KiB
Plaintext
Raw Normal View History

2018-12-07 16:17:45 +08:00
@import '../../style/mixins/index';
2018-12-07 16:17:45 +08:00
.antCheckboxFn(@checkbox-prefix-cls: ~'@{ant-prefix}-checkbox') {
@checkbox-inner-prefix-cls: ~'@{checkbox-prefix-cls}-inner';
// 一般状态
.@{checkbox-prefix-cls} {
.reset-component;
position: relative;
top: -0.09em;
display: inline-block;
line-height: 1;
white-space: nowrap;
2017-09-21 18:12:53 +08:00
vertical-align: middle;
outline: none;
cursor: pointer;
2017-03-29 11:24:35 +08:00
.@{checkbox-prefix-cls}-wrapper:hover &-inner,
2017-02-28 11:37:29 +08:00
&:hover &-inner,
&-input:focus + &-inner {
border-color: @checkbox-color;
}
&-checked::after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 1px solid @checkbox-color;
border-radius: @border-radius-sm;
visibility: hidden;
animation: antCheckboxEffect 0.36s ease-in-out;
animation-fill-mode: both;
content: '';
}
&:hover::after,
.@{checkbox-prefix-cls}-wrapper:hover &::after {
visibility: visible;
}
&-inner {
position: relative;
top: 0;
left: 0;
display: block;
2017-09-23 18:18:47 +08:00
width: @checkbox-size;
height: @checkbox-size;
background-color: @checkbox-check-color;
2018-11-13 22:48:44 +08:00
border: @checkbox-border-width @border-style-base @border-color-base;
border-radius: @border-radius-sm;
// Fix IE checked style
// https://github.com/ant-design/ant-design/issues/12597
border-collapse: separate;
transition: all 0.3s;
&::after {
2017-09-23 18:18:47 +08:00
@check-width: (@checkbox-size / 14) * 5px;
@check-height: (@checkbox-size / 14) * 8px;
position: absolute;
top: 50%;
2019-01-29 15:39:56 +08:00
left: 21%;
display: table;
2017-09-23 18:18:47 +08:00
width: @check-width;
height: @check-height;
border: 2px solid @checkbox-check-color;
border-top: 0;
border-left: 0;
transform: rotate(45deg) scale(0) translate(-50%, -50%);
2018-08-16 17:42:44 +08:00
opacity: 0;
transition: all 0.1s @ease-in-back, opacity 0.1s;
content: ' ';
}
}
&-input {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
cursor: pointer;
opacity: 0;
}
}
// 选中状态
.@{checkbox-prefix-cls}-checked .@{checkbox-inner-prefix-cls}::after {
position: absolute;
display: table;
border: 2px solid @checkbox-check-color;
border-top: 0;
border-left: 0;
transform: rotate(45deg) scale(1) translate(-50%, -50%);
2018-08-16 17:42:44 +08:00
opacity: 1;
transition: all 0.2s @ease-out-back 0.1s;
content: ' ';
}
2018-08-16 17:42:44 +08:00
.@{checkbox-prefix-cls}-checked {
.@{checkbox-inner-prefix-cls} {
background-color: @checkbox-color;
border-color: @checkbox-color;
}
}
.@{checkbox-prefix-cls}-disabled {
cursor: not-allowed;
&.@{checkbox-prefix-cls}-checked {
.@{checkbox-inner-prefix-cls}::after {
border-color: @disabled-color;
animation-name: none;
}
}
.@{checkbox-prefix-cls}-input {
cursor: not-allowed;
}
.@{checkbox-inner-prefix-cls} {
background-color: @input-disabled-bg;
border-color: @border-color-base !important;
&::after {
border-color: @input-disabled-bg;
border-collapse: separate;
animation-name: none;
}
}
2016-06-23 11:15:24 +08:00
& + span {
color: @disabled-color;
cursor: not-allowed;
2016-06-23 11:15:24 +08:00
}
}
.@{checkbox-prefix-cls}-wrapper {
.reset-component;
display: inline-block;
line-height: unset;
cursor: pointer;
2017-09-25 20:02:33 +08:00
& + & {
margin-left: 8px;
2016-06-27 14:52:46 +08:00
}
}
.@{checkbox-prefix-cls}-wrapper + span,
.@{checkbox-prefix-cls} + span {
padding-right: 8px;
padding-left: 8px;
}
.@{checkbox-prefix-cls}-group {
.reset-component;
display: inline-block;
&-item {
display: inline-block;
2017-10-17 11:06:25 +08:00
margin-right: 8px;
&:last-child {
margin-right: 0;
}
}
&-item + &-item {
margin-left: 0;
}
}
// 半选状态
.@{checkbox-prefix-cls}-indeterminate {
.@{checkbox-inner-prefix-cls} {
background-color: #fff;
border-color: @border-color-base;
}
.@{checkbox-inner-prefix-cls}::after {
@indeterminate-width: @checkbox-size - 8px;
@indeterminate-height: @checkbox-size - 8px;
top: 50%;
left: 50%;
width: @indeterminate-width;
height: @indeterminate-height;
background-color: @checkbox-color;
border: 0;
transform: translate(-50%, -50%) scale(1);
opacity: 1;
content: ' ';
}
&.@{checkbox-prefix-cls}-disabled .@{checkbox-inner-prefix-cls}::after {
background-color: @disabled-color;
border-color: @disabled-color;
}
}
}
@keyframes antCheckboxEffect {
0% {
transform: scale(1);
opacity: 0.5;
}
100% {
transform: scale(1.6);
opacity: 0;
}
}