helang-flex.scss 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * uni-app flex 布局盒子
  3. * 作者:helang
  4. * 邮箱:helang.love@qq.com
  5. */
  6. /* 分列式弹性盒子,以X轴从左到右排列 */
  7. .h-flex-x{
  8. display: flex;
  9. flex-direction: row;
  10. flex-wrap: nowrap;
  11. justify-content: flex-start;
  12. align-items: center;
  13. align-content: center;
  14. /* 水平左对齐 */
  15. &.h-flex-left{
  16. justify-content: flex-start;
  17. }
  18. /* 水平居中对齐 */
  19. &.h-flex-center{
  20. justify-content: center;
  21. }
  22. /* 水平右对齐 */
  23. &.h-flex-right{
  24. justify-content: flex-end;
  25. }
  26. /* 水平两端对齐 */
  27. &.h-flex-space{
  28. justify-content: space-between;
  29. }
  30. /* 垂直顶部对齐 */
  31. &.h-flex-top{
  32. align-items: flex-start;
  33. align-content: flex-start;
  34. }
  35. /* 垂直底部对齐 */
  36. &.h-flex-bottom{
  37. align-items: flex-end;
  38. align-content: flex-end;
  39. }
  40. /* 允许换行 */
  41. &.h-flex-wrap{
  42. flex-wrap: wrap;
  43. }
  44. /* 等比分列,2-6列 */
  45. @for $i from 2 through 6
  46. {
  47. &.h-flex-#{$i}{
  48. &>view{
  49. width:(100% / $i);
  50. }
  51. }
  52. }
  53. /* 弹性元素 */
  54. &>.h-flex-item-grow{
  55. flex-grow: 1;
  56. width:0;
  57. }
  58. }
  59. /* 分行式弹性盒子,以Y轴从上到下排列 */
  60. .h-flex-y{
  61. display: flex;
  62. flex-direction: column;
  63. flex-wrap: nowrap;
  64. justify-content: flex-start;
  65. align-items: flex-start;
  66. align-content: flex-start;
  67. /* 垂直居中对齐 */
  68. &.h-flex-center{
  69. justify-content: center;
  70. align-items: center;
  71. align-content: center;
  72. }
  73. /* 水平左对齐 */
  74. &.h-flex-left{
  75. align-items: flex-start;
  76. align-content: flex-start;
  77. }
  78. /* 水平右对齐 */
  79. &.h-flex-right{
  80. align-items: flex-end;
  81. align-content: flex-end;
  82. }
  83. /* 垂直两端对齐 */
  84. &.h-flex-space{
  85. justify-content: space-between;
  86. }
  87. /* 垂直顶部对齐 */
  88. &.h-flex-top{
  89. justify-content: flex-start;
  90. }
  91. /* 垂直底部对齐 */
  92. &.h-flex-bottom{
  93. justify-content: flex-end;
  94. }
  95. /* 等比分行,2-6行 */
  96. @for $i from 2 through 6
  97. {
  98. &.h-flex-#{$i}{
  99. &>view{
  100. height:(100% / $i);
  101. }
  102. }
  103. }
  104. /* 弹性元素 */
  105. &>.h-flex-item-grow{
  106. flex-grow: 1;
  107. height: 0;
  108. }
  109. }