<small id='7RG2U'></small><noframes id='7RG2U'>

<tfoot id='7RG2U'></tfoot>

      <bdo id='7RG2U'></bdo><ul id='7RG2U'></ul>
    <i id='7RG2U'><tr id='7RG2U'><dt id='7RG2U'><q id='7RG2U'><span id='7RG2U'><b id='7RG2U'><form id='7RG2U'><ins id='7RG2U'></ins><ul id='7RG2U'></ul><sub id='7RG2U'></sub></form><legend id='7RG2U'></legend><bdo id='7RG2U'><pre id='7RG2U'><center id='7RG2U'></center></pre></bdo></b><th id='7RG2U'></th></span></q></dt></tr></i><div id='7RG2U'><tfoot id='7RG2U'></tfoot><dl id='7RG2U'><fieldset id='7RG2U'></fieldset></dl></div>
    <legend id='7RG2U'><style id='7RG2U'><dir id='7RG2U'><q id='7RG2U'></q></dir></style></legend>
    1. img 设置 flex-grow 填充 flex 容器剩余空间,导致 flex 内部溢出 flex 容器

      img set flex-grow to fill flex container rest space, it cause flex inner overflow flex container(img 设置 flex-grow 填充 flex 容器剩余空间,导致 flex 内部溢出 flex 容器)
      <i id='spIUO'><tr id='spIUO'><dt id='spIUO'><q id='spIUO'><span id='spIUO'><b id='spIUO'><form id='spIUO'><ins id='spIUO'></ins><ul id='spIUO'></ul><sub id='spIUO'></sub></form><legend id='spIUO'></legend><bdo id='spIUO'><pre id='spIUO'><center id='spIUO'></center></pre></bdo></b><th id='spIUO'></th></span></q></dt></tr></i><div id='spIUO'><tfoot id='spIUO'></tfoot><dl id='spIUO'><fieldset id='spIUO'></fieldset></dl></div>
      • <bdo id='spIUO'></bdo><ul id='spIUO'></ul>
        1. <tfoot id='spIUO'></tfoot>

          <small id='spIUO'></small><noframes id='spIUO'>

          <legend id='spIUO'><style id='spIUO'><dir id='spIUO'><q id='spIUO'></q></dir></style></legend>

              <tbody id='spIUO'></tbody>

                本文介绍了img 设置 flex-grow 填充 flex 容器剩余空间,导致 flex 内部溢出 flex 容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                以下是我的代码,text1";溢出 flex 容器,我希望 flex 容器中的 img + text 和 img 填充 flex 容器休息

                following is my code, "text1" overflow the flex container, I expect img + text in flex container and img fill flex container rest

                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="utf-8">
                    <!--mobile friendly-->
                    <meta name="viewport" content="width=device-width, user-scalable=yes">
                    <style>
                        .c {
                            display: flex;
                            flex-direction: column;
                            width: 100px;
                            height: 100px;
                            border: 5px solid lightblue;
                        }
                
                        .c img {
                            flex-grow: 1;
                            object-fit: contain;
                        }
                    </style>
                </head>
                <body>
                <div class="c">
                    <img src="./img.jpg"/>
                    <div>text1</div>
                </div>
                </body>
                </html>
                

                结果是:

                如果元素不是 img 并且是 div,flex-grow: 1 将填充 flex rest 空间,我很困惑为什么 img 会导致内部溢出

                if element is not img and is div, flex-grow: 1 will fill flex rest space, I'm confused why img cause inner overflow

                以下是我的img.jpg"

                following is my "img.jpg"

                推荐答案

                /* CSS */
                
                .c {
                  width: 100px;
                  height: 100px;
                  border: 5px solid lightblue;
                  position: relative;
                  text-align: center;
                }
                .c img {
                  width: 100%;
                }
                .c div {
                  position: absolute;
                  top: 50%;
                  left: 50%;
                  transform: translate(-50%, -50%);
                  color: red;
                }

                <!-- HTML -->
                
                <!DOCTYPE html>
                <html lang="en">
                  <head>
                    <meta charset="utf-8">
                    <meta name="viewport" content="width=device-width, user-scalable=yes">
                  </head>
                  <body>
                    <div class="c">
                      <img src="https://i.stack.imgur.com/P5N3A.jpg" />
                      <div>text1</div>
                    </div>
                  </body>
                </html>

                这篇关于img 设置 flex-grow 填充 flex 容器剩余空间,导致 flex 内部溢出 flex 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                <i id='oiyuV'><tr id='oiyuV'><dt id='oiyuV'><q id='oiyuV'><span id='oiyuV'><b id='oiyuV'><form id='oiyuV'><ins id='oiyuV'></ins><ul id='oiyuV'></ul><sub id='oiyuV'></sub></form><legend id='oiyuV'></legend><bdo id='oiyuV'><pre id='oiyuV'><center id='oiyuV'></center></pre></bdo></b><th id='oiyuV'></th></span></q></dt></tr></i><div id='oiyuV'><tfoot id='oiyuV'></tfoot><dl id='oiyuV'><fieldset id='oiyuV'></fieldset></dl></div>

                <small id='oiyuV'></small><noframes id='oiyuV'>

                  <bdo id='oiyuV'></bdo><ul id='oiyuV'></ul>
                    <tbody id='oiyuV'></tbody>
                    • <tfoot id='oiyuV'></tfoot>

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