当前位置: 移动技术网 > IT编程>脚本编程>vue.js > vue实现长图垂直居上 vue实现短图垂直居中

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

中国新闻网首页,诚实守信手抄报,中国煤炭长安网

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

html代码(vue作用域内):

<div class="box" v-for="item in previewimg">
  <img :src="item" alt="" @load="checkheight($event)">
</div>

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');
  }

}

}

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网