zoukankan      html  css  js  c++  java
  • APP开发,发布动态、朋友圈类似,多张图片动响应式正方形展示布局 vue.js,aui.css,apicloud

    环境:vue.js,aui.css,apicloud

    1.没做控制之前。图片真实长度宽度。

    2.下面用js控制高度

    js部分

    //js 部分 
    //先动态的获取属性宽度
    var box4_col3 = document.getElementsByClassName("aui-col-xs-4")[0];
    vm.col3 = window.getComputedStyle(box4_col3).width;
    
    //vue绑定数据
    var vm = new Vue({
         el: '#app',
         data: {
             col3:'',
          }
    })

    css部分

      <div class="aui-col-xs-4" v-for="(img, index) in item.for_img"   v-bind:style=" 'overflow:hidden; height:' + col3 ">
             <img :src="xxxx" onclick="open_img_big( item.for_img, index )"/>
    </div>

     控制后 长大于宽的部分自动隐藏,但是宽大于长的会有空白显示

    3.给定义 宽高100%,图片形变压缩了

                                <div class="aui-col-xs-4" v-for="(img, index) in item.for_img"
                                     v-bind:style=" 'overflow:hidden; height:' + col3 ">
                                    <img :src="qiniu + img.qiniu_img" width="100%" height="100%"
                                         onclick="open_img_big( item.for_img, index )"/>
                                </div>

    4.调了很久,发现七牛云有缩略图配置

    我的后台图片保存用到了七牛云存储,在七牛图片加上后缀 自动居中裁剪成 正方形

    ?imageView2/1/w/300/h/300/q/80|imageslim

    以上完美显示!!!

  • 相关阅读:
    [P4721] 【模板】分治 FFT
    [GYM102452E] Erasing Numbers
    [LOJ6220] sum
    [CF776B] Sherlock and His Girlfriend
    [LOJ6087] 毒瘤题
    [LOJ2612] 花匠
    [LOJ529] 自然语言
    [CTSC2017] 吉夫特
    [LOJ6671] EntropyIncreaser 与 Minecraft
    [LOJ3196] 挂架
  • 原文地址:https://www.cnblogs.com/super-zhangkun/p/10092574.html
Copyright © 2011-2022 走看看