• <small id='SKoFP'></small><noframes id='SKoFP'>

      • <bdo id='SKoFP'></bdo><ul id='SKoFP'></ul>

      <tfoot id='SKoFP'></tfoot>
      <i id='SKoFP'><tr id='SKoFP'><dt id='SKoFP'><q id='SKoFP'><span id='SKoFP'><b id='SKoFP'><form id='SKoFP'><ins id='SKoFP'></ins><ul id='SKoFP'></ul><sub id='SKoFP'></sub></form><legend id='SKoFP'></legend><bdo id='SKoFP'><pre id='SKoFP'><center id='SKoFP'></center></pre></bdo></b><th id='SKoFP'></th></span></q></dt></tr></i><div id='SKoFP'><tfoot id='SKoFP'></tfoot><dl id='SKoFP'><fieldset id='SKoFP'></fieldset></dl></div>

    1. <legend id='SKoFP'><style id='SKoFP'><dir id='SKoFP'><q id='SKoFP'></q></dir></style></legend>

      1. 使用 CSS 居中和裁剪图像

        Center and crop image with CSS(使用 CSS 居中和裁剪图像)

            <tbody id='87JR4'></tbody>
        1. <tfoot id='87JR4'></tfoot>

          <small id='87JR4'></small><noframes id='87JR4'>

            • <bdo id='87JR4'></bdo><ul id='87JR4'></ul>
                <legend id='87JR4'><style id='87JR4'><dir id='87JR4'><q id='87JR4'></q></dir></style></legend>

                  <i id='87JR4'><tr id='87JR4'><dt id='87JR4'><q id='87JR4'><span id='87JR4'><b id='87JR4'><form id='87JR4'><ins id='87JR4'></ins><ul id='87JR4'></ul><sub id='87JR4'></sub></form><legend id='87JR4'></legend><bdo id='87JR4'><pre id='87JR4'><center id='87JR4'></center></pre></bdo></b><th id='87JR4'></th></span></q></dt></tr></i><div id='87JR4'><tfoot id='87JR4'></tfoot><dl id='87JR4'><fieldset id='87JR4'></fieldset></dl></div>
                • 本文介绍了使用 CSS 居中和裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要使用 CSS 对图像进行居中和裁剪.我已关注

                  1 - 当我在 portrait 模式下使用设备时显示

                  2 - 当我在 landscape 模式下使用设备时

                  运行时代码:

                  解决方案

                  你可以通过

                  img {适合对象:封面;}

                  它与 background-size:cover 的作用相同,但它用于 img 标签而不是背景图像

                  参考

                  I need to Center and crop image with CSS. I have followed this article.But device UI output is somewhat different. Can you explain the behavior of this?

                  This is the use case:

                  We don’t want to actually crop - just display the middle of the image. Some of the docs people will upload will be docs so don’t want this to be stretched.

                  My question is I don't know why it transforms (1 image) landscape mode even though I got the image using portrait mode? Any explanation?

                  photo {
                      .photo {
                          position: relative;
                          width: 100%;
                          height: 200px;
                          overflow: hidden;
                          img {
                              position: absolute;
                              left: 50%;
                              top: 50%;
                              height: 100%;
                              width: auto;
                              -webkit-transform: translate(-50%, -50%);
                              -ms-transform: translate(-50%, -50%);
                              transform: translate(-50%, -50%);
                          }
                          img.portrait {
                              width: 100%;
                              height: auto;
                            }
                      }
                  }

                  <div class="photo">
                    <img [src]="data?.url class="portrait">
                  </div>

                  UI:

                  1 - It shows when I used the device in portrait mode

                  2 - when I used device in landscape mode

                  Runtime code:

                  解决方案

                  You can achieve it by

                  img {
                      object-fit: cover;
                  }
                  

                  It works the same as background-size: cover but it's used for img tags instead of background images

                  Reference

                  这篇关于使用 CSS 居中和裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Plot data in website from multiple csv file(从多个 csv 文件中绘制网站中的数据)
                  Content Service for Google Apps Script returning HTML instead of JSON(返回 HTML 而不是 JSON 的 Google Apps 脚本的内容服务)
                  Javascript Confirm popup Yes, No button instead of OK and Cancel(Javascript 确认弹出窗口是,否按钮而不是确定和取消)
                  Opensource/free HTML5/CSS3/JavaScript IDE?(开源/免费 HTML5/CSS3/JavaScript IDE?)
                  jump to CSS selector in a css file from the HTML file in Vim using a single keystroke(使用单次击键从 Vim 中的 HTML 文件跳转到 CSS 文件中的 CSS 选择器)
                  Is there a good in-browser code editor?(有没有好的浏览器内代码编辑器?)
                  • <small id='PD3V9'></small><noframes id='PD3V9'>

                      <tbody id='PD3V9'></tbody>
                    <legend id='PD3V9'><style id='PD3V9'><dir id='PD3V9'><q id='PD3V9'></q></dir></style></legend>

                      <bdo id='PD3V9'></bdo><ul id='PD3V9'></ul>
                      <tfoot id='PD3V9'></tfoot>

                          1. <i id='PD3V9'><tr id='PD3V9'><dt id='PD3V9'><q id='PD3V9'><span id='PD3V9'><b id='PD3V9'><form id='PD3V9'><ins id='PD3V9'></ins><ul id='PD3V9'></ul><sub id='PD3V9'></sub></form><legend id='PD3V9'></legend><bdo id='PD3V9'><pre id='PD3V9'><center id='PD3V9'></center></pre></bdo></b><th id='PD3V9'></th></span></q></dt></tr></i><div id='PD3V9'><tfoot id='PD3V9'></tfoot><dl id='PD3V9'><fieldset id='PD3V9'></fieldset></dl></div>