一、背景图片

使用padding代替高度的原因可查阅参考1链接


固定宽高比

        .boxWrapper{
            max-width: 320px;
        }
          .box {
            width: 100%;
            height: 0;
            padding-bottom: 84.375%; /*图片宽高 320/270  270/375=84.375%*/
            background: url(/part/home2013/451/U179P4T451D5F17247DT20211216075602.jpg) no-repeat;
            background-size: cover;/*或 100% 100%*/
            background-position: center; /* 因background-size不兼容,所以设置此属性 居中显式 Internet Explorer 7/8 */
        }

流动宽高比

见参考2链接

二、图片

 见参考3链接

参考:

       https://bbs.huaweicloud.com/blogs/detail/181211


 

       

相关文章:

  • 2021-05-27
  • 2021-11-14
  • 2021-11-14
  • 2022-01-01
  • 2021-09-03
  • 2021-12-23
  • 2022-12-23
  • 2021-10-17
猜你喜欢
  • 2022-02-10
  • 2021-12-12
  • 2022-12-23
  • 2021-12-05
  • 2022-01-04
相关资源
相似解决方案