horizontal-scroll-nav.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="slot">
  3. <scroll-view class="scroll" scroll-x="true">
  4. <view class="item" v-for="(item, index) in list" :key="index">
  5. <view class="title">
  6. <image src="../../static/bg/bg-community.png"></image>
  7. <text>{{ item.text }}</text>
  8. </view>
  9. <view class="info">
  10. <image src="../../static/bg/bg-user.png"></image>
  11. <view class="num">
  12. <text>{{ item.num }}</text>
  13. <text>人参与</text>
  14. </view>
  15. </view>
  16. <u-image class="bg" width="360rpx" height="190rpx" :src="item.bg"></u-image>
  17. </view>
  18. </scroll-view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'horizontal-scroll-nav',
  24. props: {
  25. // 列表
  26. list: {
  27. type: Array,
  28. default: () => {
  29. return [];
  30. }
  31. }
  32. }
  33. };
  34. </script>
  35. <style lang="scss" scoped>
  36. .slot {
  37. height: auto;
  38. width: 100%;
  39. .scroll {
  40. width: 100%;
  41. white-space: nowrap;
  42. }
  43. .item {
  44. display: inline-block;
  45. width: 360rpx;
  46. height: 190rpx;
  47. margin-right: 30rpx;
  48. padding: 24rpx;
  49. position: relative;
  50. border-radius: 12rpx;
  51. overflow: hidden;
  52. &:nth-child(1) {
  53. margin-left: 30rpx;
  54. }
  55. .bg {
  56. position: absolute;
  57. top: 0;
  58. left: 0;
  59. border-radius: 12rpx;
  60. overflow: hidden;
  61. z-index: 19;
  62. }
  63. .title {
  64. width: calc(100% - 48rpx);
  65. position: absolute;
  66. left: 24rpx;
  67. top: 24rpx;
  68. z-index: 39;
  69. image {
  70. vertical-align: middle;
  71. padding-right: 4rpx;
  72. width: 32rpx;
  73. height: 32rpx;
  74. }
  75. text {
  76. vertical-align: middle;
  77. font-size: 28rpx;
  78. font-weight: 500;
  79. color: #ffffff;
  80. line-height: 44rpx;
  81. white-space: pre-wrap;
  82. }
  83. }
  84. .info {
  85. display: flex;
  86. align-items: center;
  87. position: absolute;
  88. left: 24rpx;
  89. bottom: 24rpx;
  90. z-index: 39;
  91. image {
  92. width: 26rpx;
  93. height: 24rpx;
  94. margin-right: 8rpx;
  95. vertical-align: middle;
  96. }
  97. .num {
  98. vertical-align: middle;
  99. font-size: 20rpx;
  100. font-weight: 500;
  101. color: #ffffff;
  102. line-height: 44rpx;
  103. text:nth-child(1) {
  104. vertical-align: middle;
  105. font-weight: bold;
  106. color: #f6f6f6;
  107. font-size: 28rpx;
  108. line-height: 2;
  109. }
  110. text:nth-child(2) {
  111. vertical-align: bottom;
  112. font-weight: bold;
  113. color: #f6f6f6;
  114. font-size: 20rpx;
  115. line-height: 2.6;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. </style>