zoukankan      html  css  js  c++  java
  • 图片 百分百

    object-fit: fill || cover || contain || none || scale-down

    fill: 中文释义“填充”。默认值。替换内容拉伸填满整个contentbox,不保证保持原有的比例。

    contain: 中文释义“包含”。保持原有尺寸比例。保证替换内容尺寸一定可以在容器里面放得下。因此,此参数可能会在容器内留下空白。
    cover: 中文释义“覆盖”。保持原有尺寸比例。保证替换内容尺寸一定大于容器尺寸,宽度和高度至少有一个和容器一致。因此,此参数可能会让替换内容(如图片)部分区域不可见(上面讲解的例子就是如此)。
    none: 中文释义“无”。保持原有尺寸比例。同时保持替换内容原始尺寸大小。
    scale-down: 中文释义“降低”。就好像依次设置了none或contain, 最终呈现的是尺寸比较小的那个。

    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            img {
                height: 200px;
                 200px;

            }

            .img-fill {
                object-fit: fill;
            }

            .img-cover {
                object-fit: cover;
            }

            .img-conatin {
                object-fit: contain;
            }

            .img-none {
                object-fit: none;
            }

            .img-sacle-down {
                object-fit: scale-down;
            }

            .box {
                display: flex;

            }

            .box>div {
                padding: 20px;
            }
        </style>
    </head>

    <body>
        <div class="box">
            <div>
                <div>原图</div>
                <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
            <div>
                <div>object-fit: fill</div>
                <img class="img-fill"
                    src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
            <div>
                <div>object-fit: cover</div>
                <img class="img-cover"
                    src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
            <div>
                <div>object-fit: contain</div>
                <img class="img-conatin"
                    src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
            <div>
                <div>object-fit: none</div>
                <img class="img-none"
                    src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
            <div>
                <div>object-fit: scale-down</div>
                <img class="img-sacle-down"
                    src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2442489277,908091175&fm=26&gp=0.jpg"
                    alt="">
            </div>
        </div>
    </body>

    </html>
  • 相关阅读:
    爬虫必看,每日JS逆向之爱奇艺密码加密,今天你练了吗?
    每日JS逆向练习之斗鱼登录密码加密,今天你练了吗?
    兄弟们,我打算抠100个网站JS加密代码召唤,一个也跑不掉,这次轮到小虎牙
    这个爬虫JS逆向加密任务,你还不来试试?逆向入门级,适合一定爬虫基础的人
    兄弟,你爬虫基础这么好,需要研究js逆向了,一起吧(有完整JS代码)
    四十一:快速排序(递归)
    第四十次发博不知道用什么标题好
    第三十九次发博不知道发什么好
    第三十八次发博不知道用什么标题好
    第三十七次发博不知道用什么标题好
  • 原文地址:https://www.cnblogs.com/HePandeFeng/p/13815447.html
Copyright © 2011-2022 走看看