ant-design/components/form/style/index.less

660 lines
14 KiB
Plaintext
Raw Normal View History

2018-12-07 16:17:45 +08:00
@import '../../style/themes/default';
@import '../../style/mixins/index';
@import '../../input/style/mixin';
@import '../../button/style/mixin';
@import '../../grid/style/mixin';
@import './mixin';
@form-prefix-cls: ~'@{ant-prefix}-form';
@form-component-height: @input-height-base;
@form-component-max-height: @input-height-lg;
@form-feedback-icon-size: @font-size-base;
@form-help-margin-top: (@form-component-height - @form-component-max-height) / 2 + 2px;
2015-06-15 11:43:18 +08:00
.@{form-prefix-cls} {
.reset-component;
.reset-form;
2015-06-15 11:43:18 +08:00
}
.@{form-prefix-cls}-item-required:before {
2016-02-02 20:47:52 +08:00
display: inline-block;
margin-right: 4px;
2018-12-07 16:17:45 +08:00
content: '*';
2016-02-02 20:47:52 +08:00
font-family: SimSun;
line-height: 1;
2016-02-02 20:47:52 +08:00
font-size: @font-size-base;
color: @label-required-color;
.@{form-prefix-cls}-hide-required-mark & {
display: none;
}
2016-02-02 20:47:52 +08:00
}
2015-07-17 15:05:12 +08:00
// Radio && Checkbox
2018-12-07 16:17:45 +08:00
input[type='radio'],
input[type='checkbox'] {
2015-07-17 15:05:12 +08:00
&[disabled],
&.disabled {
cursor: not-allowed;
2015-07-17 15:05:12 +08:00
}
}
2015-07-17 15:05:12 +08:00
// These classes are used directly on <label>s
.@{ant-prefix}-radio-inline,
.@{ant-prefix}-radio-vertical,
.@{ant-prefix}-checkbox-inline,
.@{ant-prefix}-checkbox-vertical {
&.disabled {
cursor: not-allowed;
2015-07-17 15:05:12 +08:00
}
}
2015-07-17 15:05:12 +08:00
// These classes are used on elements with <label> descendants
.@{ant-prefix}-radio,
.@{ant-prefix}-checkbox {
&.disabled {
2015-07-17 15:05:12 +08:00
label {
cursor: not-allowed;
2015-07-17 15:05:12 +08:00
}
}
}
2015-07-07 11:32:08 +08:00
// Form items
// You should wrap labels and controls in .@{form-prefix-cls}-item for optimum spacing
.@{form-prefix-cls}-item {
label {
position: relative;
> .@{iconfont-css-prefix} {
vertical-align: top;
font-size: @font-size-base;
}
}
.reset-component;
2015-07-07 11:32:08 +08:00
margin-bottom: @form-item-margin-bottom;
vertical-align: top;
2015-07-07 11:32:08 +08:00
2016-01-22 14:56:35 +08:00
&-control {
line-height: @form-component-max-height - 0.0001px; // https://github.com/ant-design/ant-design/issues/8220
2016-05-17 15:46:21 +08:00
position: relative;
2016-05-19 15:21:48 +08:00
.clearfix;
2016-01-22 14:56:35 +08:00
}
&-children {
position: relative;
}
2016-05-19 15:21:48 +08:00
&-with-help {
2018-12-07 16:17:45 +08:00
margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base -
@form-help-margin-top;
}
2016-07-10 17:04:03 +08:00
&-label {
text-align: right;
2015-07-17 15:43:31 +08:00
vertical-align: middle;
line-height: @form-component-max-height - 0.0001px;
display: inline-block;
2016-10-07 14:34:25 +08:00
overflow: hidden;
white-space: nowrap;
2015-07-22 17:17:47 +08:00
label {
color: @label-color;
&:after {
& when (@form-item-trailing-colon=true) {
2018-12-07 16:17:45 +08:00
content: ':';
}
& when not (@form-item-trailing-colon=true) {
2018-12-07 16:17:45 +08:00
content: ' ';
}
margin: 0 8px 0 2px;
position: relative;
top: -0.5px;
}
2015-07-24 16:08:44 +08:00
}
2015-07-07 11:32:08 +08:00
}
2015-07-16 22:57:47 +08:00
.@{ant-prefix}-switch {
2017-12-22 15:22:22 +08:00
margin: 2px 0 4px;
2015-07-16 22:57:47 +08:00
}
&-no-colon &-label label:after {
2018-12-07 16:17:45 +08:00
content: ' ';
}
2015-06-15 11:43:18 +08:00
}
.@{form-prefix-cls}-explain,
.@{form-prefix-cls}-extra {
color: @text-color-secondary;
// Magic tweak pixel number to float line-height diff in windows
// Fix https://github.com/ant-design/ant-design/issues/12803
line-height: @line-height-base + 0.024;
2018-12-07 16:17:45 +08:00
transition: color 0.3s @ease-out; // sync input color transition
2017-10-09 11:09:25 +08:00
margin-top: @form-help-margin-top;
clear: both;
}
.@{form-prefix-cls}-extra {
padding-top: 4px;
2016-04-25 16:25:57 +08:00
}
.@{form-prefix-cls}-text {
2015-07-20 19:25:34 +08:00
display: inline-block;
padding-right: 8px;
2015-07-20 19:25:34 +08:00
}
.@{form-prefix-cls}-split {
2015-07-20 19:25:34 +08:00
display: block;
2015-07-17 15:05:12 +08:00
text-align: center;
2015-06-15 11:43:18 +08:00
}
2015-07-07 11:32:08 +08:00
// 表单下的输入框尺寸唯一: 大尺寸
form {
.has-feedback {
.@{ant-prefix}-input {
padding-right: 24px;
}
// Fix overlapping between feedback icon and <Select>'s arrow.
// https://github.com/ant-design/ant-design/issues/4431
2017-07-21 10:07:04 +08:00
> .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
> .@{ant-prefix}-select .@{ant-prefix}-select-selection__clear,
2017-07-11 12:14:35 +08:00
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
2018-12-07 16:17:45 +08:00
:not(.@{ant-prefix}-input-group-addon)
> .@{ant-prefix}-select
.@{ant-prefix}-select-selection__clear {
2017-07-11 12:14:35 +08:00
right: 28px;
}
2017-07-21 10:07:04 +08:00
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
2018-12-07 16:17:45 +08:00
:not(.@{ant-prefix}-input-group-addon)
> .@{ant-prefix}-select
.@{ant-prefix}-select-selection-selected-value {
2017-07-11 12:14:35 +08:00
padding-right: 42px;
}
.@{ant-prefix}-cascader-picker {
&-arrow {
2017-11-10 17:15:02 +08:00
margin-right: 17px;
}
&-clear {
right: 28px;
}
}
2017-02-09 11:09:22 +08:00
// Fix issue: https://github.com/ant-design/ant-design/issues/7854
2017-10-11 10:43:59 +08:00
.@{ant-prefix}-input-search:not(.@{ant-prefix}-input-search-enter-button) {
.@{ant-prefix}-input-suffix {
right: 28px;
}
}
2017-02-09 11:09:22 +08:00
// Fix issue: https://github.com/ant-design/ant-design/issues/4783
.@{ant-prefix}-calendar-picker,
.@{ant-prefix}-time-picker {
2017-02-09 11:09:22 +08:00
&-icon,
&-clear {
right: 28px;
}
}
2015-07-07 11:32:08 +08:00
}
2015-07-21 14:54:49 +08:00
textarea.@{ant-prefix}-input {
height: auto;
margin-bottom: 4px;
}
2015-07-07 11:32:08 +08:00
// input[type=file]
.@{ant-prefix}-upload {
2015-07-08 13:17:14 +08:00
background: transparent;
2015-07-07 11:32:08 +08:00
}
2015-07-15 17:22:58 +08:00
2018-12-07 16:17:45 +08:00
input[type='radio'],
input[type='checkbox'] {
2015-07-17 15:05:12 +08:00
width: 14px;
height: 14px;
}
2015-07-15 17:22:58 +08:00
// Radios and checkboxes on same line
.@{ant-prefix}-radio-inline,
.@{ant-prefix}-checkbox-inline {
2015-07-15 17:22:58 +08:00
display: inline-block;
vertical-align: middle;
2015-06-15 20:24:01 +08:00
font-weight: normal;
cursor: pointer;
margin-left: 8px;
2015-12-16 17:39:10 +08:00
&:first-child {
margin-left: 0;
}
2015-06-15 20:24:01 +08:00
}
.@{ant-prefix}-checkbox-vertical,
.@{ant-prefix}-radio-vertical {
2015-07-17 15:05:12 +08:00
display: block;
2015-06-15 20:24:01 +08:00
}
2015-07-20 17:28:29 +08:00
.@{ant-prefix}-checkbox-vertical + .@{ant-prefix}-checkbox-vertical,
.@{ant-prefix}-radio-vertical + .@{ant-prefix}-radio-vertical {
2016-06-27 17:22:03 +08:00
margin-left: 0;
}
.@{ant-prefix}-input-number {
+ .@{form-prefix-cls}-text {
margin-left: 8px;
}
&-handler-wrap {
z-index: 2; // https://github.com/ant-design/ant-design/issues/6289
}
2015-07-20 17:28:29 +08:00
}
2015-07-20 19:25:34 +08:00
.@{ant-prefix}-select,
.@{ant-prefix}-cascader-picker {
2015-07-20 19:25:34 +08:00
width: 100%;
}
2017-06-26 21:44:38 +08:00
// Don't impact select inside input group
.@{ant-prefix}-input-group .@{ant-prefix}-select,
.@{ant-prefix}-input-group .@{ant-prefix}-cascader-picker {
width: auto;
}
// fix input with addon position. https://github.com/ant-design/ant-design/issues/8243
:not(.@{ant-prefix}-input-group-wrapper) > .@{ant-prefix}-input-group,
.@{ant-prefix}-input-group-wrapper {
display: inline-block;
2018-01-12 15:54:10 +08:00
vertical-align: middle;
position: relative;
2018-01-12 15:54:10 +08:00
top: -1px;
}
2015-06-15 20:24:01 +08:00
}
2015-12-02 19:33:26 +08:00
// Input combined with select
.@{ant-prefix}-input-group-wrap {
.@{ant-prefix}-select-selection {
2015-12-02 19:33:26 +08:00
border-bottom-left-radius: 0;
border-top-left-radius: 0;
&:hover {
2016-03-04 17:06:39 +08:00
border-color: @border-color-base;
2015-12-02 19:33:26 +08:00
}
}
.@{ant-prefix}-select-selection--single {
2015-12-02 19:33:26 +08:00
margin-left: -1px;
height: @input-height-lg;
2015-12-02 19:33:26 +08:00
background-color: #eee;
.@{ant-prefix}-select-selection__rendered {
2015-12-02 19:33:26 +08:00
padding-left: 8px;
padding-right: 25px;
line-height: 30px;
}
}
.@{ant-prefix}-select-open .@{ant-prefix}-select-selection {
2016-03-04 17:06:39 +08:00
border-color: @border-color-base;
2015-12-02 19:33:26 +08:00
box-shadow: none;
}
}
// Form layout
//== Vertical Form
.make-vertical-layout-label() {
padding: @form-vertical-label-padding;
margin: @form-vertical-label-margin;
display: block;
text-align: left;
2017-06-26 11:51:31 +08:00
line-height: @line-height-base;
2016-08-04 17:45:15 +08:00
label:after {
2017-06-25 16:48:01 +08:00
display: none;
2016-08-04 17:45:15 +08:00
}
}
2017-08-11 17:05:25 +08:00
.make-vertical-layout() {
.@{form-prefix-cls}-item-label,
.@{form-prefix-cls}-item-control-wrapper {
display: block;
width: 100%;
}
.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
.@{form-prefix-cls}-vertical .@{form-prefix-cls}-item-label,
2017-08-11 17:05:25 +08:00
// when labelCol is 24, it is a vertical form
.@{ant-prefix}-col-24.@{form-prefix-cls}-item-label,
.@{ant-prefix}-col-xl-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
2018-01-12 14:55:04 +08:00
.@{form-prefix-cls}-vertical {
.@{form-prefix-cls}-item {
padding-bottom: 8px;
}
.@{form-prefix-cls}-item-control {
line-height: @line-height-base;
}
.@{form-prefix-cls}-explain,
.@{form-prefix-cls}-extra {
margin-top: 2px;
margin-bottom: -4px;
}
}
@media (max-width: @screen-xs-max) {
.make-vertical-layout();
.@{ant-prefix}-col-xs-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
@media (max-width: @screen-sm-max) {
.@{ant-prefix}-col-sm-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
@media (max-width: @screen-md-max) {
.@{ant-prefix}-col-md-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
@media (max-width: @screen-lg-max) {
.@{ant-prefix}-col-lg-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
@media (max-width: @screen-xl-max) {
.@{ant-prefix}-col-xl-24.@{form-prefix-cls}-item-label {
.make-vertical-layout-label();
}
}
2016-08-04 17:45:15 +08:00
//== Inline Form
.@{form-prefix-cls}-inline {
.@{form-prefix-cls}-item {
display: inline-block;
2017-06-26 17:05:42 +08:00
margin-right: 16px;
margin-bottom: 0;
&-with-help {
margin-bottom: 24px;
}
> .@{form-prefix-cls}-item-control-wrapper,
> .@{form-prefix-cls}-item-label {
2015-12-08 17:48:12 +08:00
display: inline-block;
vertical-align: top;
2015-12-08 17:48:12 +08:00
}
}
2015-06-15 20:24:01 +08:00
.@{form-prefix-cls}-text {
display: inline-block;
}
.has-feedback {
display: inline-block;
}
2015-07-07 11:32:08 +08:00
}
2015-06-15 20:24:01 +08:00
2015-06-15 11:43:18 +08:00
// Validation state
2015-11-26 19:32:55 +08:00
.has-success,
.has-warning,
.has-error,
.is-validating {
2018-07-25 11:42:26 +08:00
&.has-feedback .@{form-prefix-cls}-item-children-icon {
2015-08-03 13:34:40 +08:00
position: absolute;
top: 50%;
2015-08-03 13:34:40 +08:00
right: 0;
2016-05-24 20:08:13 +08:00
visibility: visible;
pointer-events: none;
2017-12-22 17:35:55 +08:00
width: @form-component-height;
height: 20px;
line-height: 20px;
margin-top: -10px;
2015-08-03 13:34:40 +08:00
text-align: center;
2017-08-10 11:34:08 +08:00
font-size: @form-feedback-icon-size;
2018-12-07 16:17:45 +08:00
animation: zoomIn 0.3s @ease-out-back;
z-index: 1;
& svg {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
2015-08-20 14:58:09 +08:00
}
}
2015-11-18 15:41:30 +08:00
.has-success {
2018-07-25 11:42:26 +08:00
&.has-feedback .@{form-prefix-cls}-item-children-icon {
2015-11-18 15:41:30 +08:00
animation-name: diffZoomIn1 !important;
2015-08-03 13:34:40 +08:00
color: @success-color;
2015-07-07 11:32:08 +08:00
}
2015-06-15 11:43:18 +08:00
}
2015-08-03 13:34:40 +08:00
2015-06-15 11:43:18 +08:00
.has-warning {
.form-control-validation(@warning-color; @warning-color;);
2015-08-03 13:34:40 +08:00
2018-07-25 11:42:26 +08:00
&.has-feedback .@{form-prefix-cls}-item-children-icon {
2015-08-03 13:34:40 +08:00
color: @warning-color;
animation-name: diffZoomIn3 !important;
2015-08-03 13:34:40 +08:00
}
//select
.@{ant-prefix}-select {
2015-08-03 13:34:40 +08:00
&-selection {
border-color: @warning-color;
&:hover {
border-color: @warning-color;
}
2015-08-03 13:34:40 +08:00
}
2016-11-16 20:13:00 +08:00
&-open .@{ant-prefix}-select-selection,
&-focused .@{ant-prefix}-select-selection {
.active(@warning-color);
2015-08-03 13:34:40 +08:00
}
}
2016-11-16 20:13:00 +08:00
// arrow and icon
.@{ant-prefix}-calendar-picker-icon:after,
.@{ant-prefix}-time-picker-icon:after,
2016-11-16 20:13:00 +08:00
.@{ant-prefix}-picker-icon:after,
.@{ant-prefix}-select-arrow,
.@{ant-prefix}-cascader-picker-arrow {
2015-11-19 14:11:34 +08:00
color: @warning-color;
}
//input-number, timepicker
2016-09-15 01:21:48 +08:00
.@{ant-prefix}-input-number,
.@{ant-prefix}-time-picker-input {
border-color: @warning-color;
2016-11-11 15:08:02 +08:00
&-focused,
&:focus {
.active(@warning-color);
}
2015-11-18 15:41:30 +08:00
&:not([disabled]):hover {
border-color: @warning-color;
}
}
2017-10-09 13:46:56 +08:00
.@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input {
.active(@warning-color);
}
2015-06-15 11:43:18 +08:00
}
2015-08-03 13:34:40 +08:00
2015-06-15 11:43:18 +08:00
.has-error {
.form-control-validation(@error-color; @error-color;);
2015-08-03 13:34:40 +08:00
2018-07-25 11:42:26 +08:00
&.has-feedback .@{form-prefix-cls}-item-children-icon {
2015-08-03 13:34:40 +08:00
color: @error-color;
animation-name: diffZoomIn2 !important;
2015-08-03 13:34:40 +08:00
}
2015-08-20 14:58:09 +08:00
//select
.@{ant-prefix}-select {
2015-08-03 13:34:40 +08:00
&-selection {
border-color: @error-color;
&:hover {
border-color: @error-color;
}
}
2016-11-16 20:13:00 +08:00
&-open .@{ant-prefix}-select-selection,
&-focused .@{ant-prefix}-select-selection {
2016-08-31 17:04:24 +08:00
.active(@error-color);
2015-08-03 13:34:40 +08:00
}
}
2018-01-31 10:47:25 +08:00
.@{ant-prefix}-select.@{ant-prefix}-select-auto-complete {
.@{ant-prefix}-input:focus {
border-color: @error-color;
}
}
.@{ant-prefix}-input-group-addon .@{ant-prefix}-select {
&-selection {
border-color: transparent;
box-shadow: none;
}
}
2016-11-16 20:13:00 +08:00
// arrow and icon
.@{ant-prefix}-calendar-picker-icon:after,
.@{ant-prefix}-time-picker-icon:after,
2016-11-16 20:13:00 +08:00
.@{ant-prefix}-picker-icon:after,
.@{ant-prefix}-select-arrow,
.@{ant-prefix}-cascader-picker-arrow {
2015-11-19 14:11:34 +08:00
color: @error-color;
}
//input-number, timepicker
2016-09-15 01:21:48 +08:00
.@{ant-prefix}-input-number,
.@{ant-prefix}-time-picker-input {
border-color: @error-color;
2016-11-11 15:08:02 +08:00
&-focused,
&:focus {
.active(@error-color);
}
2015-11-18 15:41:30 +08:00
&:not([disabled]):hover {
border-color: @error-color;
}
}
2016-11-11 15:08:02 +08:00
.@{ant-prefix}-mention-wrapper {
.@{ant-prefix}-mention-editor {
2016-11-11 15:08:02 +08:00
&,
&:not([disabled]):hover {
border-color: @error-color;
}
}
2017-09-25 22:53:11 +08:00
&.@{ant-prefix}-mention-active:not([disabled]) .@{ant-prefix}-mention-editor,
2016-11-11 15:08:02 +08:00
.@{ant-prefix}-mention-editor:not([disabled]):focus {
.active(@error-color);
}
}
2017-10-09 13:46:56 +08:00
.@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input {
.active(@error-color);
}
// transfer
.@{ant-prefix}-transfer {
&-list {
border-color: @error-color;
&-search:not([disabled]) {
border-color: @input-border-color;
&:hover {
.hover();
}
&:focus {
.active();
}
}
}
}
2015-08-03 13:34:40 +08:00
}
.is-validating {
2018-07-25 11:42:26 +08:00
&.has-feedback .@{form-prefix-cls}-item-children-icon {
2015-08-03 13:34:40 +08:00
display: inline-block;
2017-01-14 20:59:37 +08:00
color: @primary-color;
2015-08-03 13:34:40 +08:00
}
2015-06-15 11:43:18 +08:00
}
2015-08-20 14:58:09 +08:00
.@{ant-prefix}-advanced-search-form {
.@{form-prefix-cls}-item {
margin-bottom: @form-item-margin-bottom;
&-with-help {
2018-12-07 16:17:45 +08:00
margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base -
@form-help-margin-top;
}
2016-04-12 14:55:02 +08:00
}
}
2017-08-11 17:05:25 +08:00
.show-help-motion(@className, @keyframeName, @duration: @animation-duration-slow) {
.make-motion(@className, @keyframeName, @duration);
.@{className}-enter,
.@{className}-appear {
opacity: 0;
animation-timing-function: @ease-in-out;
}
.@{className}-leave {
animation-timing-function: @ease-in-out;
}
}
.show-help-motion(show-help, antShowHelp, 0.3s);
2017-08-11 17:05:25 +08:00
@keyframes antShowHelpIn {
0% {
opacity: 0;
transform: translateY(-5px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@keyframes antShowHelpOut {
to {
opacity: 0;
transform: translateY(-5px);
}
}
2015-11-18 15:41:30 +08:00
// need there different zoom animation
// otherwise won't trigger anim
@keyframes diffZoomIn1 {
2015-11-26 19:32:55 +08:00
0% {
2015-08-20 14:58:09 +08:00
transform: scale(0);
}
2015-11-26 19:32:55 +08:00
100% {
2015-08-20 14:58:09 +08:00
transform: scale(1);
}
}
2015-11-18 15:41:30 +08:00
@keyframes diffZoomIn2 {
2015-11-26 19:32:55 +08:00
0% {
2015-11-18 15:41:30 +08:00
transform: scale(0);
}
2015-11-26 19:32:55 +08:00
100% {
2015-11-18 15:41:30 +08:00
transform: scale(1);
}
}
@keyframes diffZoomIn3 {
2015-11-26 19:32:55 +08:00
0% {
2015-08-20 14:58:09 +08:00
transform: scale(0);
}
2015-11-26 19:32:55 +08:00
100% {
2015-08-20 14:58:09 +08:00
transform: scale(1);
}
}