• css img图片和背景图片按容器大小自适应大小(居中裁切)


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title></title>
            <style>
                * {
                    margin: 0;
                    padding: 0;
                }
            </style>
            <script>
               
            </script>
        </head>
    
        <body>
    
            <div style=" 100%;height:200px;background:#000;display: flex;align-items: center;justify-content: center;">
                <div
                    style=" 200px;height:100%;background: red;display: flex;align-items: center;justify-content: center;overflow: hidden;">
                    <div
                        style="background: url('../5562.jpg_wh300.jpg') no-repeat fixed center top; 100%;height:100%;background-size: auto 200px;">
                    </div>
                </div>
            </div>
            <div style=" 100%;height:200px;background:#000;display: flex;align-items: center;justify-content: center;">
                <div
                    style=" 200px;height:100%;background: red;display: flex;align-items: center;justify-content: center;overflow: hidden;">
                    <img src="../5562.jpg_wh300.jpg" style="max-height: 100%;" />
                </div>
            </div>
        </body>
    </html>

    效果图:

    使用图片:

  • 相关阅读:
    #define中的特殊符号
    c++ windows下计时
    c++内存池
    u3d 场景资源打包
    Unity3d 动态加载材质方法
    Unity3D Shader基础教程
    Unity3D Shader入门指南(一)
    Unreal发展史
    阴影锥(shadow volume)原理与展望
    软硬RAID 和 不常见的RAID
  • 原文地址:https://www.cnblogs.com/fanqiuzhuji/p/13492680.html
Copyright © 2020-2023  润新知