ytwanzi

1.轮播图外层容器swiper,每一个轮播项swiper-item

2.swiper标签存在默认样式

 width 100%  

 height 150px

 image 存在默认宽度和高度 320*240

 swiper 高度无法实现由内容撑开

3.综上,需先根据原图的宽度和高度 等比例给swiper定宽度和高度

 假定:原图宽度和高度为 640 * 200px

 swiper 宽度 / swiper 高度 = 原图的宽度 / 原图的高度

 则 swiper 高度 = swiper 宽度 * 原图的高度 / 原图的宽度

    即 height: 100vw * 200 / 640

4.css样式

 swiper{ 

    width: 100%;
    height: calc(100vw * 200 / 640);
 }
 image{
    width: 100%;
 }
5.给image标签添加mode属性:mode="widthFix"
 宽度100%,高度自适应

分类:

技术点:

相关文章:

  • 2021-05-06
  • 2022-12-23
  • 2021-10-28
  • 2021-08-31
  • 2021-08-24
  • 2021-12-15
猜你喜欢
  • 2021-10-06
  • 2021-06-30
  • 2022-01-08
相关资源
相似解决方案