flex.scss 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. // .u-flex {
  2. // @include vue-flex(row);
  3. // }
  4. // .u-flex-x {
  5. // @include vue-flex(row);
  6. // }
  7. // .u-flex-y {
  8. // @include vue-flex(column);
  9. // }
  10. // .u-flex-xy-center {
  11. // @include vue-flex(row);
  12. // justify-content: center;
  13. // align-items: center;
  14. // }
  15. // .u-flex-x-center {
  16. // @include vue-flex(row);
  17. // justify-content: center;
  18. // }
  19. // .u-flex-y-center {
  20. // @include vue-flex(column);
  21. // justify-content: center;
  22. // }
  23. // flex布局
  24. .u-flex,
  25. .u-flex-row,
  26. .u-flex-x,
  27. .up-flex,
  28. .up-flex-row,
  29. .up-flex-x {
  30. @include flex;
  31. display: flex !important;
  32. flex-direction: row !important;
  33. }
  34. .u-flex-y,
  35. .u-flex-column,
  36. .up-flex-y,
  37. .up-flex-column {
  38. @include flex(column);
  39. display: flex !important;
  40. flex-direction: column !important;
  41. }
  42. .u-flex-x-center,
  43. .up-flex-x-center {
  44. @include flex;
  45. justify-content: center !important;
  46. }
  47. .u-flex-xy-center,
  48. .up-flex-xy-center {
  49. @include flex;
  50. justify-content: center !important;
  51. align-items: center !important;
  52. }
  53. .u-flex-y-center,
  54. .up-flex-y-center {
  55. @include flex;
  56. align-items: center !important;
  57. }
  58. .u-flex-x-left,
  59. .up-flex-x-left {
  60. @include flex;
  61. }
  62. .u-flex-x-reverse,
  63. .u-flex-row-reverse,
  64. .up-flex-x-reverse,
  65. .up-flex-row-reverse {
  66. flex-direction: row-reverse !important;
  67. }
  68. .u-flex-y-reverse,
  69. .u-flex-column-reverse,
  70. .up-flex-y-reverse,
  71. .up-flex-column-reverse {
  72. flex-direction: column-reverse !important;
  73. }
  74. /* #ifndef APP-NVUE */
  75. // 此处为vue版本的简写,因为nvue不支持同时作用于两个类名的样式写法
  76. // nvue下只能写成class="u-flex-x u-flex-x-reverse的形式"
  77. .u-flex.u-flex-reverse,
  78. .u-flex-row.u-flex-reverse,
  79. .u-flex-x.u-flex-reverse,
  80. .up-flex.up-flex-reverse,
  81. .up-flex-row.up-flex-reverse,
  82. .up-flex-x.up-flex-reverse {
  83. flex-direction: row-reverse !important;
  84. }
  85. .u-flex-column.u-flex-reverse,
  86. .u-flex-y.u-flex-reverse,
  87. .up-flex-column.up-flex-reverse,
  88. .up-flex-y.up-flex-reverse {
  89. flex-direction: column-reverse !important;
  90. }
  91. // 自动伸缩
  92. .u-flex-fill,
  93. .up-flex-fill {
  94. flex: 1 1 auto !important;
  95. }
  96. // 边界自动伸缩
  97. .u-margin-top-auto,
  98. .u-m-t-auto,
  99. .up-margin-top-auto,
  100. .up-m-t-auto {
  101. margin-top: auto !important;
  102. }
  103. .u-margin-right-auto,
  104. .u-m-r-auto,
  105. .up-margin-right-auto,
  106. .up-m-r-auto {
  107. margin-right: auto !important;
  108. }
  109. .u-margin-bottom-auto,
  110. .u-m-b-auto,
  111. .up-margin-bottom-auto,
  112. .up-m-b-auto {
  113. margin-bottom: auto !important;
  114. }
  115. .u-margin-left-auto,
  116. .u-m-l-auto,
  117. .up-margin-left-auto,
  118. .up-m-l-auto {
  119. margin-left: auto !important;
  120. }
  121. .u-margin-center-auto,
  122. .u-m-c-auto,
  123. .up-margin-center-auto,
  124. .up-m-c-auto {
  125. margin-left: auto !important;
  126. margin-right: auto !important;
  127. }
  128. .u-margin-middle-auto,
  129. .u-m-m-auto,
  130. .up-margin-middle-auto,
  131. .up-m-m-auto {
  132. margin-top: auto !important;
  133. margin-bottom: auto !important;
  134. }
  135. /* #endif */
  136. // 换行
  137. .u-flex-wrap,
  138. .up-flex-wrap {
  139. flex-wrap: wrap !important;
  140. }
  141. // 反向换行
  142. .u-flex-wrap-reverse,
  143. .up-flex-wrap-reverse {
  144. flex-wrap: wrap-reverse !important;
  145. }
  146. // 主轴起点对齐
  147. .u-flex-start,
  148. .up-flex-start {
  149. justify-content: flex-start !important;
  150. }
  151. // 主轴中间对齐
  152. .u-flex-center,
  153. .up-flex-center {
  154. justify-content: center !important;
  155. }
  156. // 主轴终点对齐
  157. .u-flex-end,
  158. .up-flex-end {
  159. justify-content: flex-end !important;
  160. }
  161. // 主轴等比间距
  162. .u-flex-between,
  163. .up-flex-between {
  164. justify-content: space-between !important;
  165. }
  166. // 主轴均分间距
  167. .u-flex-around,
  168. .up-flex-around {
  169. justify-content: space-around !important;
  170. }
  171. // 交叉轴起点对齐
  172. .u-flex-items-start,
  173. .up-flex-items-start {
  174. align-items: flex-start !important;
  175. }
  176. // 交叉轴中间对齐
  177. .u-flex-items-center,
  178. .up-flex-items-center {
  179. align-items: center !important;
  180. }
  181. // 交叉轴终点对齐
  182. .u-flex-items-end,
  183. .up-flex-items-end {
  184. align-items: flex-end !important;
  185. }
  186. // 交叉轴第一行文字基线对齐
  187. .u-flex-items-baseline,
  188. .up-flex-items-baseline {
  189. /* #ifndef APP-NVUE */
  190. align-items: baseline !important;
  191. /* #endif */
  192. }
  193. // 交叉轴方向拉伸对齐
  194. .u-flex-items-stretch,
  195. .up-flex-items-stretch {
  196. align-items: stretch !important;
  197. }
  198. // 以下属于项目(子元素)的类
  199. // 子元素交叉轴起点对齐
  200. /* #ifndef APP-NVUE */
  201. .u-flex-self-start,
  202. .up-flex-self-start {
  203. align-self: flex-start !important;
  204. }
  205. // 子元素交叉轴居中对齐
  206. .u-flex-self-center,
  207. .up-flex-self-center {
  208. align-self: center !important;
  209. }
  210. // 子元素交叉轴终点对齐
  211. .u-flex-self-end,
  212. .up-flex-self-end {
  213. align-self: flex-en !important;
  214. }
  215. // 子元素交叉轴第一行文字基线对齐
  216. .u-flex-self-baseline,
  217. .up-flex-self-baseline {
  218. align-self: baseline !important;
  219. }
  220. // 子元素交叉轴方向拉伸对齐
  221. .u-flex-self-stretch,
  222. .up-flex-self-stretch {
  223. align-self: stretch !important;
  224. }
  225. /* #endif */
  226. // 多轴交叉时的对齐方式
  227. // 起点对齐
  228. /* #ifndef APP-NVUE */
  229. .u-flex-content-start,
  230. .up-flex-content-start {
  231. align-content: flex-start !important;
  232. }
  233. // 居中对齐
  234. .u-flex-content-center,
  235. .up-flex-content-center {
  236. align-content: center !important;
  237. }
  238. // 终点对齐
  239. .u-flex-content-end,
  240. .up-flex-content-end {
  241. align-content: flex-end !important;
  242. }
  243. // 两端对齐
  244. .u-flex-content-between,
  245. .up-flex-content-between {
  246. align-content: space-between !important;
  247. }
  248. // 均分间距
  249. .u-flex-content-around,
  250. .up-flex-content-around {
  251. align-content: space-around !important;
  252. }
  253. // 全部居中对齐
  254. .u-flex-middle,
  255. .up-flex-middle {
  256. justify-content: center !important;
  257. align-items: center !important;
  258. align-self: center !important;
  259. align-content: center !important;
  260. }
  261. // 是否可以放大
  262. .u-flex-grow,
  263. .up-flex-grow {
  264. flex-grow: 1 !important;
  265. }
  266. // 是否可以缩小
  267. .u-flex-shrink,
  268. .up-flex-shrink {
  269. flex-shrink: 1 !important;
  270. }
  271. /* #endif */
  272. // 定义内外边距,历遍1-80
  273. @for $i from 0 through 80 {
  274. // 只要双数和能被5除尽的数
  275. @if $i % 2 == 0 or $i % 5 == 0 {
  276. // 得出:up-margin-30或者u-m-30
  277. .u-margin-#{$i}, .u-m-#{$i},
  278. .up-margin-#{$i}, .up-m-#{$i} {
  279. margin: $i + rpx!important;
  280. }
  281. // 得出:up-padding-30或者u-p-30
  282. .u-padding-#{$i}, .u-p-#{$i},
  283. .up-padding-#{$i}, .up-p-#{$i} {
  284. padding: $i + rpx!important;
  285. }
  286. @each $short, $long in l left, t top, r right, b bottom {
  287. // 缩写版,结果如: up-m-l-30
  288. // 定义外边距
  289. .u-m-#{$short}-#{$i},
  290. .up-m-#{$short}-#{$i} {
  291. margin-#{$long}: $i + rpx!important;
  292. }
  293. // 定义内边距
  294. .u-p-#{$short}-#{$i},
  295. .up-p-#{$short}-#{$i} {
  296. padding-#{$long}: $i + rpx!important;
  297. }
  298. // 完整版,结果如:up-margin-left-30
  299. // 定义外边距
  300. .u-margin-#{$long}-#{$i},
  301. .up-margin-#{$long}-#{$i} {
  302. margin-#{$long}: $i + rpx!important;
  303. }
  304. // 定义内边距
  305. .u-padding-#{$long}-#{$i},
  306. .up-padding-#{$long}-#{$i} {
  307. padding-#{$long}: $i + rpx!important;
  308. }
  309. }
  310. }
  311. }