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

564 lines
12 KiB
Plaintext
Raw Normal View History

@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-lg;
2017-08-10 11:34:08 +08:00
@form-feedback-icon-size: 14px;
2015-06-15 11:43:18 +08:00
.reset-form();
2015-07-07 11:32:08 +08:00
label {
position: relative;
> .@{iconfont-css-prefix} {
vertical-align: top;
2015-07-08 12:02:57 +08:00
font-size: @font-size-base;
2015-07-07 11:32:08 +08:00
}
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;
content: "*";
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
input[type="radio"],
input[type="checkbox"] {
&[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 {
2015-09-14 20:22:31 +08:00
font-size: @font-size-base;
2015-07-07 11:32:08 +08:00
margin-bottom: @form-item-margin-bottom;
2016-11-08 20:50:59 +08:00
color: @text-color;
vertical-align: top;
2015-07-07 11:32:08 +08:00
2016-05-19 15:21:48 +08:00
// nested FormItem
&-control > &:last-child,
& [class^="@{ant-prefix}-col-"] > &:only-child {
2016-05-19 15:21:48 +08:00
margin-bottom: -@form-item-margin-bottom;
}
2016-01-22 14:56:35 +08:00
&-control {
line-height: @form-component-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
}
2016-05-19 15:21:48 +08:00
&-with-help {
margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base;
}
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-height;
display: inline-block;
2016-10-07 14:34:25 +08:00
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
2015-07-22 17:17:47 +08:00
label {
color: @label-color;
&:after {
& when (@form-item-trailing-colon=true) {
content: ":";
}
& when not (@form-item-trailing-colon=true) {
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 {
2015-07-16 22:57:47 +08:00
margin: 4px 0;
}
&-no-colon &-label label:after {
content: " ";
}
2015-06-15 11:43:18 +08:00
}
.@{form-prefix-cls}-explain,
.@{form-prefix-cls}-extra {
color: @text-color-secondary;
line-height: 1.5;
}
.@{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,
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-selection__clear {
right: 28px;
}
2017-07-21 10:07:04 +08:00
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
2017-07-11 12:14:35 +08:00
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value {
padding-right: 42px;
}
.@{ant-prefix}-cascader-picker {
&-arrow {
margin-right: 21px;
}
&-clear {
right: 28px;
}
}
2017-02-09 11:09:22 +08:00
// Fix issue: https://github.com/ant-design/ant-design/issues/7854
.@{ant-prefix}-input-search {
.@{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;
}
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
2015-07-17 15:05:12 +08:00
input[type="radio"],
input[type="checkbox"] {
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 {
2015-07-20 17:43:01 +08:00
margin-right: 8px;
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%;
// Fix https://github.com/ant-design/ant-design/issues/6097
&:only-child {
display: block;
}
2015-07-20 19:25:34 +08:00
}
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;
}
// Don't impact select inside input group addon
.@{ant-prefix}-input-group-addon .@{ant-prefix}-select,
.@{ant-prefix}-input-group-addon .@{ant-prefix}-cascader-picker {
&:only-child {
display: inline-block;
}
}
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;
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() {
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
}
}
.@{form-prefix-cls}-vertical .@{form-prefix-cls}-item-label,
// 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();
}
@media (max-width: @screen-xs-max) {
.@{ant-prefix}-col-xs-24.@{form-prefix-cls}-item-label {
.make-vertical-layout();
}
}
@media (max-width: @screen-sm-max) {
.@{ant-prefix}-col-sm-24.@{form-prefix-cls}-item-label {
.make-vertical-layout();
}
}
@media (max-width: @screen-md-max) {
.@{ant-prefix}-col-md-24.@{form-prefix-cls}-item-label {
.make-vertical-layout();
}
}
@media (max-width: @screen-lg-max) {
.@{ant-prefix}-col-lg-24.@{form-prefix-cls}-item-label {
.make-vertical-layout();
}
}
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;
}
> div {
2015-12-08 17:48:12 +08:00
display: inline-block;
vertical-align: middle;
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;
}
// Fix https://github.com/ant-design/ant-design/issues/1040
.@{form-prefix-cls}-explain {
position: absolute;
}
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 {
2015-08-03 13:34:40 +08:00
&.has-feedback:after {
position: absolute;
top: 0;
2015-08-03 13:34:40 +08:00
right: 0;
2016-05-24 20:08:13 +08:00
visibility: visible;
pointer-events: none;
2015-08-04 14:41:30 +08:00
.square(@input-height-lg);
2016-06-28 18:32:03 +08:00
line-height: @input-height-lg;
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;
2016-04-19 15:15:54 +08:00
animation: zoomIn .3s @ease-out-back;
2016-07-25 14:03:56 +08:00
.iconfont-font("");
z-index: 1;
2015-08-20 14:58:09 +08:00
}
}
2015-11-18 15:41:30 +08:00
.has-success {
2015-08-20 18:09:28 +08:00
&.has-feedback:after {
2015-11-18 15:41:30 +08:00
animation-name: diffZoomIn1 !important;
2015-08-20 14:58:09 +08:00
}
}
2015-11-18 15:41:30 +08:00
.has-error {
2015-08-20 18:09:28 +08:00
&.has-feedback:after {
2015-11-18 15:41:30 +08:00
animation-name: diffZoomIn2 !important;
}
}
.has-warning {
&.has-feedback:after {
animation-name: diffZoomIn3 !important;
2015-08-03 13:34:40 +08:00
}
}
2015-06-15 11:43:18 +08:00
.has-success {
2015-08-03 13:34:40 +08:00
&.has-feedback:after {
content: '\e630';
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
&.has-feedback:after {
content: '\e62c';
2015-08-03 13:34:40 +08:00
color: @warning-color;
}
//select
.@{ant-prefix}-select {
2015-08-03 13:34:40 +08:00
&-selection {
border-color: @warning-color;
}
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
&.has-feedback:after {
content: '\e62e';
2015-08-03 13:34:40 +08:00
color: @error-color;
}
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;
}
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
}
}
.@{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);
}
2015-08-03 13:34:40 +08:00
}
.is-validating {
&.has-feedback:after {
display: inline-block;
2016-04-19 15:15:54 +08:00
animation: loadingCircle 1s infinite linear;
2017-01-14 20:59:37 +08:00
content: "\e64d";
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 {
2016-04-12 14:55:02 +08:00
margin-bottom: 16px;
}
.@{ant-prefix}-input,
.@{ant-prefix}-input-group .@{ant-prefix}-input,
.@{ant-prefix}-input-group .@{ant-prefix}-input-group-addon {
height: @input-height-base;
2016-04-12 14:55:02 +08:00
}
}
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);
}
}