首页 > 其他 > 详细

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

时间:2019-01-08 13:43:23      阅读:129      评论:0      收藏:0      [点我收藏+]
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;
    }                                    

 

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

原文:https://www.cnblogs.com/aloehui/p/10238299.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!