图片适应屏幕居中显示,且不变形

Posted aloehui

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图片适应屏幕居中显示,且不变形相关的知识,希望对你有一定的参考价值。

html<div class=‘item‘>
    <div class = ‘container‘ />
</div>
css:

    .item {
        width: 100%;
        height: 100%;
           .container  {
              max-width: 100%;
              height: auto;
              min-height: 720px;
              position: absolute;
              left: 50%;
              top: 50%;
              transform: translate(-50%, -50%);  // 利用位移实现居中                               
              background-image: url(./img/1.png);
              background-size: 100%;
              background-repeat: no-repeat;
              background-position: center 0;
    }                                    

 

以上是关于图片适应屏幕居中显示,且不变形的主要内容,如果未能解决你的问题,请参考以下文章