vue 彈性布局 實現長圖垂直居上,短圖垂直居中


vue 彈性布局 實現長圖垂直居上,短圖垂直居中

大致效果如下圖,只考慮垂直方向。長圖可以通過滾動條看,短圖居中效果,布局合理

  

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

}

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM