经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » 微信小程序 » 查看文章
微信小程序实现Timeline时间线效果
来源:jb51  时间:2022/5/23 10:37:03  对本文有异议

微信小程序实现类似elementUI的Timeline时间线效果,自适应页面与文本

wxml代码:

  1. <view class="box">
  2. ? <view wx:for="{{list}}" wx:key="index" class="one">
  3. ? ? <view class="onedot"></view>
  4. ? ? <view wx:if="{{index!=list.length-1}}" class="oneline"></view>
  5. ? ? <view class="onemain">
  6. ? ? ? <view class="onemaintitle">{{item.time}}</view>
  7. ? ? ? <view class="onemaincon">{{item.con}}</view>
  8. ? ? </view>
  9. ? </view>
  10. </view>

wxss代码:

  1. .box {
  2. ? padding: 30rpx;
  3. }
  4. .one {
  5. ? position: relative;
  6. ? padding-bottom: 40rpx;
  7. }
  8. .onedot {
  9. ? left: -2rpx;
  10. ? width: 24rpx;
  11. ? height: 24rpx;
  12. ? position: absolute;
  13. ? background-color: #67c23a;
  14. ? border-radius: 50%;
  15. ? display: flex;
  16. ? justify-content: center;
  17. ? align-items: center;
  18. ? z-index: 1;
  19. }
  20. .oneline {
  21. ? position: absolute;
  22. ? left: 8rpx;
  23. ? height: 100%;
  24. ? border-left: 2px solid #e4e7ed;
  25. }
  26. .onemain {
  27. ? position: relative;
  28. ? padding-left: 56rpx;
  29. ? top: -6rpx;
  30. }
  31. .onemaintitle {
  32. ? margin-bottom: 16rpx;
  33. ? padding-top: 8rpx;
  34. ? color: #909399;
  35. ? line-height: 1;
  36. ? font-size: 26rpx;
  37. }
  38. .onemaincon {
  39. ? color: #303133;
  40. }

js代码:

  1. data: {
  2. ? ? list: [{
  3. ? ? ? time: "2021-02-02 10:30:30",
  4. ? ? ? con: "这是主要内容部分"
  5. ? ? },{
  6. ? ? ? time: "2021-02-02 10:30:30",
  7. ? ? ? con: "这是主要内容部分这是主要内容部分这是主要内容部分这是主要内容部分这是主要内容部分"
  8. ? ? },{
  9. ? ? ? time: "2021-02-02 10:30:30",
  10. ? ? ? con: "这是主要内容部分这是主要内容部分这是主要内容部分这是主要内容部分"
  11. ? ? }]
  12. ? },

最终效果:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号