让图片适应容器大小,不至于太大,超出屏幕


CSS样式:

    <style type="text/css">
    .pic {
        width:900px;
        height:1000px;
        border:1px solid black;
        display: table-cell;
        vertical-align: middle;
      }
    .pic img  {
        max-width: 100%;
        max-height: 100%;
        display: block;
        margin: auto;
      }
    </style>;
 

 

使用:

  <div class="pic">   
    <img src='../00Pic/201102/20110217_1245_154.jpg' />
  </div>


参考文章:css实现图片自适应容器的几种方式:https://blog.csdn.net/llll789789/article/details/97306638