• css+background实现 图片宽高自适应,拉伸裁剪不变形


    图片宽高不固定 ,一样实现自适应,拉伸裁剪不变形,适应各大兼容性。


     下面咱们在网上找两张宽高不一样的照片:

              No.1                                              No.2

          

    从上图看一个宽的一个窄的,很难做到自适应,无奈可恶的产品经理,只能自己想办法了

     请看下面图片,经在各大浏览器和手机端测试,是好用的                       


            

      咱们先来个对比:

        好用                                                不好用

    下面是调试好用的代码:直接放个div就OK啦。


    <div style="
      500px;
      height:600px;
      border: 1px solid #000000;
      background: url(http://img.zcool.cn/community/01b34f58eee017a8012049efcfaf50.jpg@1280w_1l_2o_100sh.jpg) no-repeat;
      background-size:cover;
      background-position: center center;
    ">
    </div>
    <div style="
      500px;
      height:600px;
      border: 1px solid #000000;
      background: url(http://img17.3lian.com/d/file/201703/07/4ceeb6fc3d7956ac7731290a603e0a84.jpg) no-repeat;
      background-size:cover;
      background-position: center center;
    ">
    </div>
  • 相关阅读:
    115今天太给力了~
    使用jQuery顺序显示元素
    温习浏览器渲染模式
    去除浏览器a标签链接时,烦人的虚线框
    设计可以是一种垄断
    如何获取鼠标选中的文字
    积极参与到FuckIE6的队伍中...
    google今儿发现页面又变好看了
    20101207google 今天出新功能了
    火狐ff下margintop太给力
  • 原文地址:https://www.cnblogs.com/xianxianxxx/p/9203058.html
Copyright © 2020-2023  润新知