zoukankan      html  css  js  c++  java
  • css控制图片不改变原比例居中显示,图片超出div部分隐藏

    html部分

              <h2>图片预览</h2>
              <div class="md-camera" @click="previewImg">
                  <img class="cameraImg" :src="preImgSrc" alt>
              </div>
    

    css部分

     .md-camera {
            height: 340px;
             100%;
            border-radius: 10px;
            border: 1px dashed rgba(208, 205, 207, 1);
            overflow: hidden;
            box-sizing: border-box;
            display: flex;
            justify-content: center;
            align-items: center;
    
            .cameraImg {
               100%;
             }
    }
    


    点击查看大图
    html部分

     <!-- 蒙版 -->
        <div class="mask" v-if="preStatus">
          <span @click="closePre">×</span>
          <div class="pre" v-if="showIV">
            <img class="preImg" :src="preImgSrc" alt>
          </div>
        </div>
    

    css部分

     //   蒙版 -- 预览
      .mask {
        position: fixed;
        top: 0;
        left: 0;
         100%;
        height: 100vh;
        background: rgba(0, 0, 0, 1);
        .px2rem(10);
        padding: 0 @px2rem;
    
        span {
          display: block;
          .px2rem(80);
          color: #ffffff;
          font-size: @px2rem;
        }
    
        span {
          position: absolute;
          .px2rem(20);
          left: @px2rem;
          // top: @px2rem;
        }
    
        .pre {
           100%;
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
          .px2rem(360);
          margin-top: -@px2rem;
          margin: auto;
    
          .preImg {
             100%;
            height: 100%;
            display: block;
          }
    
          img {
             auto;
            height: auto;
            max- 100%;
            max-height: 100%;
            display: block;
          }
        }
      }
    

  • 相关阅读:
    git功能速查
    iPad actionsjeet
    iOS开发中集成Reveal
    【转】ios内联函数 inline
    【转】数据存储——APP 缓存数据线程安全问题探讨
    iOS 改变导航栏高度
    ios 闪屏页的设置
    AFNetworking content type not support
    iOS 获取本地文件的各种坑
    iOS UICollectionView 长按移动cell
  • 原文地址:https://www.cnblogs.com/jessie-xian/p/11596753.html
Copyright © 2011-2022 走看看