_form.scss 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. @charset "utf-8";
  2. /*
  3. * @file: 表单UI组件
  4. * @update: 2015-06-05 16:45:01
  5. */
  6. /*
  7. * 默认表单
  8. * @base
  9. */
  10. $label-width: 110px; // label宽度
  11. $label-adjust: 10px; // label右边距
  12. $item-adjust: 15px; // 每一行之间的间距
  13. $input-height: 30px; // input输入框高度
  14. $input-color: #666; // 输入框边文本颜色
  15. $input-border-color: #ccc; // 输入框边颜色
  16. $upload-file-width: 214px; // 普通型文件上传总宽度
  17. $upload-file-height: 30px; // 普通型文件上传高度
  18. .ui-form {
  19. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  20. font-size: 12px;
  21. line-height: 1.5;
  22. }
  23. .ui-form__item {
  24. @include clearfix;
  25. padding: 0 5px $item-adjust ($label-width + $label-adjust);
  26. // overflow: hidden;
  27. // zoom: 1;
  28. /*
  29. * 表单验证提示
  30. * @state: error
  31. */
  32. &.is-error {
  33. .ui-input {
  34. border-color: $danger-color;
  35. }
  36. .ui-form__tips {
  37. color: $danger-color;
  38. }
  39. }
  40. }
  41. .ui-form__label {
  42. float: left;
  43. width: $label-width;
  44. margin-left: -($label-width + $label-adjust);
  45. padding-top: 6px;
  46. text-align: right;
  47. }
  48. .ui-form__tips {
  49. margin-left: 5px;
  50. color: #999;
  51. }
  52. .ui-form__required {
  53. font-family: SimSun;
  54. color: $danger-color;
  55. margin-right: 2px;
  56. }
  57. .ui-form__control {
  58. .ui-btn {
  59. margin-right: 10px;
  60. }
  61. }
  62. .ui-form__multi {
  63. .ui-input {
  64. margin-bottom: 10px;
  65. &:last-of-type {
  66. margin-bottom: 0;
  67. }
  68. }
  69. }
  70. /*
  71. * 说明文本独立一行
  72. * @extend: blockTips
  73. */
  74. .ui-form {
  75. &.ext-blockTips {
  76. .ui-form__tips {
  77. display: block;
  78. padding-top: 8px;
  79. }
  80. }
  81. }
  82. /*
  83. * 标签左对齐
  84. * @extend: alignLeft
  85. */
  86. $label-width--left: 60px; // label宽度
  87. .ui-form {
  88. &.ext-alignLeft {
  89. .ui-form__item {
  90. padding-left: $label-width--left + $label-adjust;
  91. }
  92. .ui-form__label {
  93. width: $label-width--left;
  94. margin-left: -$label-width--left - $label-adjust;
  95. text-align: left;
  96. }
  97. .ui-form__required {
  98. margin-left: 2px;
  99. }
  100. }
  101. }
  102. /*
  103. * 标签顶部对齐
  104. * @extend: stacked
  105. */
  106. .ui-form {
  107. &.ext-stacked {
  108. padding-left: 0;
  109. .ui-form__item {
  110. padding-left: 0;
  111. }
  112. .ui-form__label {
  113. float: none;
  114. width: auto;
  115. display: block;
  116. margin-left: 0;
  117. padding-top: 0;
  118. padding-bottom: 5px;
  119. text-align: left;
  120. }
  121. .ui-form__required {
  122. margin-left: 2px;
  123. }
  124. }
  125. }
  126. /*
  127. * 内联表单
  128. * @extend: inline
  129. */
  130. .ui-form {
  131. &.ext-inline {
  132. padding-left: 0;
  133. .ui-form__item {
  134. @include inline-block;
  135. padding-right: 15px;
  136. padding-left: 0;
  137. vertical-align: middle;
  138. }
  139. .ui-form__label {
  140. @include inline-block;
  141. float: none;
  142. margin-left: 0;
  143. width: auto;
  144. margin-right: 10px;
  145. }
  146. }
  147. }
  148. /*
  149. * 无lable标签
  150. * @extend: noLabel
  151. */
  152. .ui-form {
  153. &.ext-noLabel {
  154. .ui-form__item {
  155. padding-left: 0;
  156. }
  157. }
  158. }
  159. /*
  160. * 栅格化多列表单
  161. * @extend: multiCol
  162. */
  163. .ui-form {
  164. &.ext-multiCol {
  165. letter-spacing: -.31em;
  166. *letter-spacing: normal;
  167. *word-spacing: -.43em;
  168. font-family: FreeSans, Arimo, "Droid Sans", Helvetica, Arial, sans-serif;
  169. text-rendering: optimizespeed;
  170. display: -webkit-flex;
  171. -webkit-flex-flow: row wrap;
  172. display: -ms-flexbox;
  173. -ms-flex-flow: row wrap;
  174. .ui-form__item {
  175. @include inline-block(top, true);
  176. letter-spacing: normal;
  177. word-spacing: normal;
  178. text-rendering: auto;
  179. padding: 0 0 15px;
  180. }
  181. .ui-form__label {
  182. display: block;
  183. float: none;
  184. margin: 0 0 5px;
  185. padding: 0;
  186. text-align: left;
  187. }
  188. .ui-form__control {
  189. display: block;
  190. width: 100% !important;
  191. }
  192. }
  193. /*
  194. * 2列栅格化
  195. * @extend: ext-grid2
  196. */
  197. &.ext-grid2 {
  198. .ui-form__item {
  199. width: 50%;
  200. *width: 49.9690%;
  201. }
  202. }
  203. /*
  204. * 3列栅格化
  205. * @extend: ext-grid3
  206. */
  207. &.ext-grid3 {
  208. .ui-form__item {
  209. width: 33.3333%;
  210. *width: 33.3023%;
  211. }
  212. }
  213. /*
  214. * 4列栅格化
  215. * @extend: ext-grid4
  216. */
  217. &.ext-grid4 {
  218. .ui-form__item {
  219. width: 25%;
  220. *width: 24.9690%;
  221. }
  222. }
  223. }
  224. /* ============================ 以下为表单控件 ============================ */
  225. /*
  226. * 单行输入框
  227. * @module: input
  228. */
  229. .ui-input,
  230. %ui-input {
  231. height: $input-height - 10;
  232. line-height: $input-height - 10;
  233. padding: 4px 5px;
  234. vertical-align: middle;
  235. border: 1px solid $input-border-color;
  236. color: $input-color;
  237. }
  238. /*
  239. * 输入框组
  240. * @base
  241. */
  242. .ui-inputGroup {
  243. font-size: 0; // 所有浏览器
  244. *word-spacing: -1px; // IE6/7
  245. * {
  246. font-size: 12px;
  247. vertical-align: top;
  248. letter-spacing: normal;
  249. word-spacing: normal;
  250. }
  251. .ui-input,
  252. .ui-btn {
  253. position: relative;
  254. &:focus {
  255. z-index: 2;
  256. }
  257. }
  258. }
  259. @media (-webkit-min-device-pixel-ratio:0) {
  260. .ui-inputGroup {
  261. letter-spacing: -5px; // Safari 5- 等不支持 font-size: 0 的浏览器
  262. }
  263. }
  264. .ui-inputGroup__addon {
  265. @extend %ui-input;
  266. @include inline-block;
  267. width: auto;
  268. min-width: 16px;
  269. margin-right: -1px;
  270. text-align: center;
  271. background-color: #eee;
  272. color: #666;
  273. }
  274. /*
  275. * 附加输入框
  276. * @extend: append
  277. */
  278. .ui-inputGroup {
  279. &.ext-append {
  280. .ui-inputGroup__addon,
  281. .ui-btn {
  282. margin-left: -1px;
  283. }
  284. }
  285. }
  286. /*
  287. * 文本域
  288. * @base
  289. */
  290. .ui-textarea {
  291. padding: 4px 5px;
  292. border: 1px solid $input-border-color;
  293. color: $input-color;
  294. }
  295. /*
  296. * 下拉选择/单选/多选框
  297. * @base: select/radio/checkbox
  298. */
  299. input[type="radio"] {
  300. margin: 2px 0;
  301. *margin-top: 0;
  302. }
  303. input[type="checkbox"] {
  304. margin: 3px 0;
  305. *margin-top: 0;
  306. }
  307. .ui-select {
  308. vertical-align: middle;
  309. margin-right: 5px;
  310. }
  311. .ui-form__txt,
  312. .ui-radio,
  313. .ui-checkbox,
  314. .ui-fileInput {
  315. @include inline-block;
  316. vertical-align: middle;
  317. // _vertical-align: 0;
  318. margin: 5px 12px 0 0;
  319. }
  320. .ui-radio,
  321. .ui-checkbox {
  322. input[type="radio"],
  323. input[type="checkbox"] {
  324. float: left;
  325. margin-right: 5px;
  326. }
  327. }
  328. /*
  329. * 文件上传
  330. * @base
  331. */
  332. .ui-upload {
  333. position: relative;
  334. font-size: 0;
  335. .ui-input {
  336. margin-right: 10px;
  337. font-size: 12px;
  338. }
  339. }
  340. .ui-upload__file {
  341. position: absolute;
  342. top: 0;
  343. left: 0;
  344. @include opacity(0, true);
  345. width: $upload-file-width;
  346. height: $upload-file-height;
  347. line-height: $upload-file-height;
  348. font-size: 12px;
  349. cursor: pointer;
  350. }
  351. /*
  352. * 文件上传
  353. * @extend: single
  354. */
  355. .ui-upload {
  356. &.ext-single {
  357. @include inline-block;
  358. vertical-align: middle;
  359. position: relative;
  360. overflow: hidden;
  361. .ui-upload__file {
  362. right: 0;
  363. left: auto;
  364. height: 100%;
  365. font-size: 26px;
  366. }
  367. }
  368. }
  369. /*
  370. * 禁用只读状态
  371. * @base
  372. */
  373. input[disabled],
  374. select[disabled],
  375. textarea[disabled],
  376. input[readonly],
  377. select[readonly],
  378. textarea[readonly] {
  379. color: $disabled-text-color;
  380. // padding: 4px;
  381. background-color: $disabled-bg-color;
  382. border: 1px solid #ddd;
  383. }
  384. input[disabled],
  385. select[disabled],
  386. textarea[disabled] {
  387. cursor: not-allowed;
  388. }
  389. input[readonly],
  390. select[readonly],
  391. textarea[readonly] {
  392. color: #999;
  393. cursor: text;
  394. background-color: #f7f7f7;
  395. }