zoukankan      html  css  js  c++  java
  • 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>

    效果图:

    使用图片:

  • 相关阅读:
    WSGI原理
    主从数据库
    mysql高级
    记录
    获取当前时间
    sql注入和防sql注入
    python操作MySQL
    修改Windows10 命令终端cmd的编码为UTF-8
    MySQL查询
    MySQL数据库操作
  • 原文地址:https://www.cnblogs.com/fanqiuzhuji/p/13492680.html
Copyright © 2011-2022 走看看