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

  • 相关阅读:
    c++作用域运算符---7
    REDIS类和方法说明
    netty WEBSOKET 客户端 JAVA
    出入库算法
    演讲的要义
    别人的面试经历
    在线表单生成器
    windows server 2012 安装 VC14(VC2015) 安装失败解决方案
    esxi 配置 交换主机 虚拟机交换机 linux centos 配置双网卡
    Linux下开发常用配置
  • 原文地址:https://www.cnblogs.com/jessie-xian/p/11596767.html
Copyright © 2011-2022 走看看