ant-design/style/components/form.less

464 lines
8.3 KiB
Plaintext
Raw Normal View History

2015-06-15 11:43:18 +08:00
@import "../mixins/index";
.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
}
2016-02-03 14:00:38 +08:00
.@{css-prefix}form-item-required:before {
2016-02-02 20:47:52 +08:00
display: inline-block;
margin-right: 4px;
content: "*";
font-family: SimSun;
font-size: @font-size-base;
color: @label-required-color;
}
2015-07-17 15:05:12 +08:00
// Input styles
.@{css-prefix}input {
.input;
}
//== Input type: with extra icon
.has-feedback {
.input-with-icon();
}
//== Style for input-group: input with label, with button or dropdown...
.@{css-prefix}input-group {
2015-07-21 14:54:49 +08:00
.input-group(~"@{css-prefix}input");
2015-07-17 15:05:12 +08:00
}
// Radio && Checkbox
input[type="radio"],
input[type="checkbox"] {
&[disabled],
&.disabled,
fieldset[disabled] & {
cursor: @cursor-disabled;
}
}
// These classes are used directly on <label>s
.@{css-prefix}radio-inline,
.@{css-prefix}radio-vertical,
.@{css-prefix}checkbox-inline,
.@{css-prefix}checkbox-vertical {
&.disabled,
fieldset[disabled] & {
cursor: @cursor-disabled;
}
}
// These classes are used on elements with <label> descendants
.@{css-prefix}radio,
.@{css-prefix}checkbox {
&.disabled,
fieldset[disabled] & {
label {
cursor: @cursor-disabled;
}
}
}
2015-07-07 11:32:08 +08:00
// Form items
// You should wrap labels and controls in .@{css-prefix}form-item for optimum spacing
2015-06-15 11:43:18 +08:00
.@{css-prefix}form-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;
2015-07-22 17:17:47 +08:00
color: #666;
2015-07-07 11:32:08 +08:00
2016-01-22 14:56:35 +08:00
&-control {
line-height: 32px;
}
&.@{css-prefix}form-item-with-help {
margin-bottom: @form-item-margin-bottom - @font-size-base * @line-height-base;
}
2015-07-16 14:18:03 +08:00
> label {
2015-07-07 11:32:08 +08:00
color: @label-color;
text-align: right;
2015-07-17 15:43:31 +08:00
vertical-align: middle;
padding-top: 7px;
padding-bottom: 7px;
2015-07-22 17:17:47 +08:00
&:lang(en) {
padding-right: 8px;
2015-07-24 16:08:44 +08:00
}
2015-07-07 11:32:08 +08:00
}
2015-07-16 22:57:47 +08:00
.@{css-prefix}switch {
margin: 4px 0;
}
2015-06-15 11:43:18 +08:00
}
.@{css-prefix}form-explain {
line-height: 1.5;
margin-top: 3px;
}
2016-04-25 16:25:57 +08:00
.@{css-prefix}form-explain,
.@{css-prefix}form-extra {
color: #999;
}
2015-07-20 19:25:34 +08:00
.@{css-prefix}form-text {
display: inline-block;
padding-right: 8px;
2015-07-20 19:25:34 +08:00
}
2015-07-17 15:05:12 +08:00
.@{css-prefix}form-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 {
.@{iconfont-css-prefix} {
.square(@input-height-lg);
line-height: @input-height-lg;
}
.@{css-prefix}input {
padding-right: 24px;
}
2015-07-07 11:32:08 +08:00
}
2015-07-08 20:12:49 +08:00
.@{css-prefix}input,
.@{css-prefix}input-group .@{css-prefix}input,
2015-07-21 14:54:49 +08:00
.@{css-prefix}input-group .@{css-prefix}input-group-addon {
2015-08-04 14:41:30 +08:00
.input-lg();
2015-07-21 14:54:49 +08:00
}
textarea.@{css-prefix}input {
height: auto;
}
2015-07-07 11:32:08 +08:00
// input[type=file]
.@{css-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
.@{css-prefix}radio-inline,
.@{css-prefix}checkbox-inline {
display: inline-block;
vertical-align: middle;
2015-06-15 20:24:01 +08:00
font-weight: normal;
cursor: pointer;
2015-12-16 17:39:10 +08:00
margin-left: 16px;
&:first-child {
margin-left: 0;
}
2015-06-15 20:24:01 +08:00
}
2015-07-17 15:05:12 +08:00
.@{css-prefix}checkbox-vertical,
.@{css-prefix}radio-vertical {
display: block;
2015-06-15 20:24:01 +08:00
}
2015-07-20 17:28:29 +08:00
2015-08-20 16:55:42 +08:00
.@{input-number-prefix-cls} {
2015-07-20 17:43:01 +08:00
margin-top: -1px;
margin-right: 8px;
2015-07-20 17:28:29 +08:00
}
2015-07-20 19:25:34 +08:00
2015-12-31 17:17:10 +08:00
.@{select-prefix-cls} {
2015-07-20 19:25:34 +08:00
width: 100%;
}
2015-06-15 20:24:01 +08:00
}
2015-12-02 19:33:26 +08:00
// Input combined with select
.@{css-prefix}input-group-wrap {
2015-12-02 19:33:26 +08:00
.@{select-prefix-cls}-selection {
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
}
}
.@{select-prefix-cls}-selection--single {
margin-left: -1px;
height: @input-height-lg;
background-color: #eee;
.@{select-prefix-cls}-selection__rendered {
padding-left: 8px;
padding-right: 25px;
line-height: 30px;
}
}
.@{select-prefix-cls}-open .@{select-prefix-cls}-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;
}
}
.ant-search-input {
&.ant-input-group .ant-input:first-child {
border-radius: @border-radius-base;
}
.ant-search-btn {
.btn-default;
border-radius: 0 @border-radius-base - 1 @border-radius-base - 1 0;
2016-03-25 19:58:57 +08:00
margin-left: -100%;
left: -1px;
2015-12-02 19:33:26 +08:00
position: relative;
border-width: 0 0 0 1px;
z-index: 2;
padding-left: 8px;
padding-right: 8px;
&:hover {
border-color: @border-color-base;
}
2015-12-28 18:05:14 +08:00
form & {
padding-top: 6px;
padding-bottom: 6px;
}
2015-12-02 19:33:26 +08:00
}
&&-focus .ant-search-btn-noempty,
&:hover .ant-search-btn-noempty {
.btn-primary;
}
}
2015-06-15 11:43:18 +08:00
// Form layout
//== Horizontal Form
.@{css-prefix}form-horizontal {
.@{css-prefix}form-item {
.make-row;
}
2015-07-17 15:05:12 +08:00
.@{css-prefix}radio-inline,
.@{css-prefix}checkbox-inline,
.@{css-prefix}input {
2015-07-17 15:05:12 +08:00
vertical-align: top;
}
2015-06-15 11:43:18 +08:00
}
//== Inline Form
.@{css-prefix}form-inline {
.@{css-prefix}form-item {
display: inline-block;
margin-right: 10px;
margin-bottom: 0;
&-with-help {
margin-bottom: 24px;
}
2015-12-08 17:48:12 +08:00
> div {
display: inline-block;
}
}
2015-06-15 11:43:18 +08:00
.@{css-prefix}input {
display: inline-block;
width: auto;
vertical-align: middle;
}
2015-06-15 11:43:18 +08:00
.@{css-prefix}form-text {
display: inline-block;
}
2015-06-15 20:24:01 +08:00
.has-feedback {
display: inline-block;
2015-07-07 11:32:08 +08:00
}
// Fix https://github.com/ant-design/ant-design/issues/1040
.@{css-prefix}form-explain {
position: absolute;
}
2015-07-07 11:32:08 +08:00
}
2015-06-15 20:24:01 +08:00
2015-11-26 19:32:55 +08:00
.@{css-prefix}form-horizontal,
.@{css-prefix}form-inline {
2015-07-07 11:32:08 +08:00
label {
2015-07-16 14:18:03 +08:00
> input[type="radio"],
2015-07-17 11:06:38 +08:00
> input[type="checkbox"] {
margin-right: 4px;
2015-07-16 14:18:03 +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;
font-family: "anticon" !important;
2015-08-04 14:41:30 +08:00
.square(@input-height-lg);
line-height: @input-height-lg;
2015-08-03 13:34:40 +08:00
text-align: center;
font-size: 14px;
2015-08-20 14:58:09 +08:00
.animation(zoomIn .3s @ease-out-back);
}
}
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-07-07 11:32:08 +08:00
.form-control-validation(@success-color; @input-hover-border-color;);
.@{css-prefix}input {
border-color: @input-border-color;
2015-08-03 13:34:40 +08:00
box-shadow: none;
}
&.has-feedback:after {
2015-11-12 22:59:25 +08:00
content: '\e62f';
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 {
2015-11-12 22:59:25 +08:00
content: '\e634';
2015-08-03 13:34:40 +08:00
color: @warning-color;
}
// ant-select
2015-08-20 16:55:42 +08:00
.@{select-prefix-cls} {
2015-08-03 13:34:40 +08:00
&-selection {
border-color: @warning-color;
box-shadow: 0 0 0 2px tint(@warning-color, 80%);
}
&-arrow {
color: @warning-color;
}
}
// ant-datepicker
2015-08-20 16:55:42 +08:00
.@{calendar-prefix-cls}-picker-icon:after {
2015-08-03 13:34:40 +08:00
color: @warning-color;
}
2015-11-19 14:11:34 +08:00
// ant-timepicker
.@{timepicker-prefix-cls}-picker-icon:after {
color: @warning-color;
}
// ant-input-number
.@{input-number-prefix-cls} {
border-color: @warning-color;
box-shadow: 0 0 0 2px tint(@warning-color, 80%);
2015-11-18 15:41:30 +08:00
&:not([disabled]):hover {
border-color: @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 {
2015-11-12 22:59:25 +08:00
content: '\e634';
2015-08-03 13:34:40 +08:00
color: @error-color;
}
2015-08-20 14:58:09 +08:00
2015-08-03 13:34:40 +08:00
// ant-select
2015-08-20 16:55:42 +08:00
.@{select-prefix-cls} {
2015-08-03 13:34:40 +08:00
&-selection {
border-color: @error-color;
box-shadow: 0 0 0 2px tint(@error-color, 80%);
}
&-arrow {
color: @error-color;
}
}
.@{select-prefix-cls}-combobox .@{select-prefix-cls}-search__field:focus {
box-shadow: none;
}
2015-08-03 13:34:40 +08:00
// ant-datepicker
2015-08-20 16:55:42 +08:00
.@{calendar-prefix-cls}-picker-icon:after {
2015-08-03 13:34:40 +08:00
color: @error-color;
}
2015-11-19 14:11:34 +08:00
// ant-timepicker
.@{timepicker-prefix-cls}-picker-icon:after {
color: @error-color;
}
// ant-input-number
.@{input-number-prefix-cls} {
border-color: @error-color;
box-shadow: 0 0 0 2px tint(@error-color, 80%);
2015-11-18 15:41:30 +08:00
&:not([disabled]):hover {
border-color: @error-color;
}
}
2015-08-03 13:34:40 +08:00
}
.is-validating {
&.has-feedback:after {
display: inline-block;
2015-11-26 19:32:55 +08:00
.animation(loadingCircle 1s infinite linear);
content: "\e6a1";
2015-08-03 13:34:40 +08:00
}
2015-06-15 11:43:18 +08:00
}
2015-08-20 14:58:09 +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);
}
}