ElementUi Carousel 走马灯轮播图,el-carousel左右箭头位置调整

Bertha 。 2021-09-08 10:58 4447阅读 0赞

效果如下:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NDMwMDAw_size_16_color_FFFFFF_t_70

原理:

手动切换

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM1NDMwMDAw_size_16_color_FFFFFF_t_70 1

  1. <template>
  2. <section class="excellentCases">
  3. <p class="title">箭头轮播图</p>
  4. <div class="baseContent">
  5. <div class="prev">
  6. <img src="~/assets/images/solution/wisdomGov/prev.png" @click="arrowClick('prev')" />
  7. </div>
  8. <div class="carousel">
  9. <el-carousel :autoplay="false" arrow="never" indicator-position="outside" ref="cardShow" >
  10. <el-carousel-item v-for="(item, index) in 4" :key="index">
  11. <h3>{
  12. { item }}</h3>
  13. </el-carousel-item>
  14. </el-carousel>
  15. </div>
  16. <div class="next">
  17. <img src="~/assets/images/solution/wisdomGov/next.png" @click="arrowClick('next')"/>
  18. </div>
  19. </div>
  20. </section>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {};
  26. },
  27. created() {},
  28. mounted() {},
  29. methods: {
  30. arrowClick(val) {
  31. if(val === 'next') {
  32. this.$refs.cardShow.next()
  33. } else {
  34. this.$refs.cardShow.prev()
  35. }
  36. },
  37. },
  38. };
  39. </script>
  40. <style scoped lang="scss">
  41. .excellentCases {
  42. max-width: 1426px;
  43. height: 530px;
  44. margin: 0 auto;
  45. background: #323233;
  46. .title{
  47. font-size: 34px;
  48. font-weight: 500;
  49. line-height: 34px;
  50. color: #FFFFFF;
  51. text-align: center;
  52. margin: 56px 0 27px 0;
  53. }
  54. .baseContent{
  55. position: relative;
  56. .prev{
  57. position: absolute;
  58. left: 46px;
  59. top:34%;
  60. img{
  61. width: 75px;
  62. height: 74px;
  63. }
  64. }
  65. .next{
  66. position: absolute;
  67. right: 46px;
  68. top:34%;
  69. img{
  70. width: 75px;
  71. height: 74px;
  72. }
  73. }
  74. .carousel{
  75. width: 1110px;
  76. // height: 347px;
  77. margin: 0 auto;
  78. background-color: #cccc;
  79. /deep/.el-carousel__container{
  80. height: 347px;
  81. }
  82. /deep/ .el-carousel__indicators--outside{
  83. background-color: #323233;;
  84. }
  85. }
  86. }
  87. }
  88. @media screen and (max-width: 992px) {
  89. }
  90. </style>

如果要完全手写,也可以参考我另外一篇文章

https://blog.csdn.net/qq_35430000/article/details/118111225

发表评论

表情:
评论列表 (有 0 条评论,4447人围观)

还没有评论,来说两句吧...

相关阅读

    相关 vue-carousel

    单页面开发中,经常需要用到轮播展示相关信息,那么vue中该怎么使用轮播图呢?这次小编给大家介绍在vue中使用vue-carousel做轮播。 首先安装vue-carouse