大致效果如下图,只考虑垂直方向。长图可以通过滚动条看,短图居中效果,布局合理

vue实现长图垂直居上 vue实现短图垂直居中

html代码(vue作用域内):

<div class="box" v-for="item in previewImg">
  <img :src="/UploadFiles/2021-04-02/item">

css代码:

.box{
 height: 100%;//如高度等于网页高度
 overflow: auto;
 display: flex;
 flex-direction: column;
 justify-content: space-around;
}
.swiper-slide.long{
 justify-content: flex-start;
}

js代码(vue作用域内,使用jquery):

methods: {
checkHeight:function (event) {
  var el=$(event.currentTarget);
  el.parent().removeClass('long');
  //this.CH 为网页高度
  if(el.height()>this.CH){
    el.parent().addClass('long');
  }

}

}

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

标签:
vue弹性布局,vue长图垂直居上,vue短图垂直居中

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com